views:

46

answers:

2

Hi,

A few days ago I asked about passing a data structure from java to perl and vice versa, and one of the recos was JSON. I played with it (mainly using Gson for java) and it seems quite nice. The only problem is I have references inside my data structure (to other objects inside the same data structure). Currently, each such reference is "translated" fully so actually each object is duplicated many times, and you can't tell all those references pointed to the same object.

Is there someway to pass info from java to per and vice versa, preferably in a human readable format, that also keeps the data about references instead duplicating values?

Thamks, Dave

+4  A: 

Similar to JSON is "YAML", and YAML allows for exactly what you describe. I believe that there's a YAML parser for Perl and I know there's one for Java because I use it in a current application.

http://yaml.org/

Pointy
YAML::XS (http://search.cpan.org/dist/YAML-LibYAML/) is currently the best YAML parser for Perl.
cjm
+2  A: 

I would suggest Inline::Java for accessing Java class from Perl and vice versa,. Once you have that interface running, you can easily access methods and attributes from the class.

Nikhil Jain