Jruby 1.4 - Yecht - How to convert YAML-String to object

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

On Mon, Mar 8, 2010 at 3:16 AM, Marco D. [email protected] 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

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 D. [email protected] wrote:

On Mon, Mar 8, 2010 at 3:16 AM, Marco D. [email protected] wrote:


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

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 N. schrieb:

http://xircles.codehaus.org/manage_email

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

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 N. schrieb:

On Tue, Mar 9, 2010 at 1:26 AM, Marco D. [email protected] 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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs