BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Sojo converts Java object graphs into JSON, XML-RPC

Sojo converts Java object graphs into JSON, XML-RPC

Sojo, a young project on SourceForge, allows you to convert Java object graphs into a specific structure (CSV, JSON, XML, etc). It also supports cloning whole graphs, filtering graphs to only retrieve certain properties and traversing the graph.

Sojo, which released version 0.3 earlier this month, was cretaed to help Java communicate with other systems by using intermediate forms for objects. Sojo is pluggable to allow you to create your own conversion format. During the conversion, Sojo performs cycle detection. Other uses for Sojo include:

  • Copy of clone object graphs
  • Compare complex object graphs
  • Traverse object graphs

The Sojo user manual provides code snippets for these activities, including copying an object graph:

Node node = new Node("Node");  
Node childNode1 = new Node("Child-Node-1");
Node childNode2 = new Node("Child-Node-2");
node.getChilds().add(childNode1);
node.getChilds().add(childNode2);

Node nodeCopy = (Node) new ObjectUtil().copy(node);

JavaLobby has a post showing how to filter object graphs by property.

Rate this Article

Adoption
Style

BT