passing a data structure from java to perl (and vice versa)

一个人想着一个人 提交于 2020-01-02 07:10:56

问题


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?


回答1:


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/




回答2:


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.



来源:https://stackoverflow.com/questions/3362939/passing-a-data-structure-from-java-to-perl-and-vice-versa

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!