Forum: JRuby Jruby 1.4 - Yecht - How to convert YAML-String to object

Posted by Marco Dohnke (marcodohnke)
on 2010-03-08 10:18
(Received via mailing list)
Hello there,

I try to convert a YAML-String (created with SnakeYAML) to a Java 
object.
Is this possible somehow?


I tried to do it with YAML.object_maker but I am getting a
NullPointerException when I try to access the instance variables.

I use JRuby 1.4, so it is Yecht as YAML-Processor.

kind regards,
Marco

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Posted by Charles Nutter (headius)
on 2010-03-08 17:20
(Received via mailing list)
On Mon, Mar 8, 2010 at 3:16 AM, Marco Dohnke <dohnke@bfpi.de> wrote:
> Hello there,
>
> I try to convert a YAML-String (created with SnakeYAML) to a Java object.
> Is this possible somehow?
>
>
> I tried to do it with YAML.object_maker but I am getting a
> NullPointerException when I try to access the instance variables.
>
> I use JRuby 1.4, so it is Yecht as YAML-Processor.

I'm confused...are you trying to turn YAML source (as a string) into a
Java YAML thingy using JRuby's YAML support?

- Charlie

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Posted by Marco Dohnke (marcodohnke)
on 2010-03-09 08:26
(Received via mailing list)
Hi,

I'm getting a String (sent by a third party lib) which is formatted as
YAML, produced by SnakeYAML. This string describes a Java object. The
Java class is in the classpath. I now want to convert this string (which
represents an object) into a Ruby/Jruby/Java object. This object makes
it possible to interact with.
In MRI this is possible. I tried in Jruby:

YAML.object_maker(JavaClass, YAML.load(string).value)

The object is created but when I call a method on it or call a property,
I am getting a NullPointerException (and jirb quits).

Hope it's more clearly now.

kind regards,
Marco

Charles Oliver Nutter schrieb:
>>
>
>     http://xircles.codehaus.org/manage_email
>
>
>
>   

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Posted by Charles Nutter (headius)
on 2010-03-11 17:24
(Received via mailing list)
Ok, it sounds like an interesting case. I assume by "describes a Java
object" you mean that SnakeYAML has embedded Java type and instance
data into the YAML so it can be deserialized back to a Java object.
This is probably simply a case we don't have implemented in our YAML
parser, since it's based on the Ruby implementation of YAML.

Can you submit this as a feature request at http://bugs.jruby.org
please, ideally with some sample YAML or a Java+YAML+Ruby example
based on using SnakeYAML?

On Tue, Mar 9, 2010 at 1:26 AM, Marco Dohnke <dohnke@bfpi.de> wrote:
>
>> On Mon, Mar 8, 2010 at 3:16 AM, Marco Dohnke <dohnke@bfpi.de> wrote:
>>>
>>
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Posted by Marco Dohnke (marcodohnke)
on 2010-03-15 17:36
(Received via mailing list)
Hi,

You are right. Our partner serializes Java objects with SnakeYAML, I try
to deserialize these Strings to Java/JRuby objects.
I'll post a feature request tomorrow. Therefore I construct some 
samples.

Thanks for your reply =)

Bye,
Marco

Charles Oliver Nutter schrieb:
> On Tue, Mar 9, 2010 at 1:26 AM, Marco Dohnke <dohnke@bfpi.de> wrote:
>> YAML.object_maker(JavaClass, YAML.load(string).value)
>>     
>>>> NullPointerException when I try to access the instance variables.
>>> To unsubscribe from this list, please visit:
>>   http://xircles.codehaus.org/manage_email
>
>
>   

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.