I have a graph created using JgraphT where I have some data associated with every Node. I need to create a JSON representation of this graph.
For instance I have 3 vertexes : A->B and A->C where A is a parent of B and C. Every node has some data associated with it. A ( dataPoint1 , ... , dataPointN ).
I want to create a JSON object that should look like that :
element {
"nodeId" : "A",
"dataPoint1" : "value1",
.....
"dataPoint2" : "value2",
"children" : [
{
"nodeId" : "B",
"dataPoint1" : "value211",
.....
"dataPoint2" : "value221"
},
{
"nodeId" : "C",
"dataPoint1" : "value221",
.....
"dataPoint2" : "value222"
}
]
}
I can probably use BreadthIterator and generate a JSON string and then convert it to JSON object, but I am wondering if there is an existing API that allows me to do it. I am pretty sure someone already implemented something like that.