Nested Json

I have a JSON -
{“key”:“Ga”, “category”:“Conditional”, “ActivityName”:“Condition”},
{“key”:“Gb”, “category”:“Outcome”, “group”:“undefined”, “ActivityName”:“Outcome1”, “Name”:"", “XPath”:""},
{“key”:“Gc”, “category”:“Outcome”, “group”:“undefined”, “ActivityName”:“Outcome2”, “Name”:"", “XPath”:""},
{“category”:“Parallel”, “ActivityName”:“Parallel”, “key”:-8},

Want it like this -
{“category”:“Condition”, “ActivityName”:“SOMETHING”, “key”:“Ga”, “Outcomes”:[{ “Name”:“Duplicate”, “XPath”:"//hasDuplicates=True",“key”:”GB”},{“Name”:“NonDuplicate”, “XPath”:"//hasDuplicates=False",“key”:”GC”}]}

How can i achieve this?

i am using GraphLinksModel. Is it possible to use this model instead of treemodel and get the desired JSON format. Any Sample which i can refer which has nested JSON object?

You have to transform the JSON.parse’d objects so that you end up with an Array of top-level Objects, each corresponding to a Node. This should be easy to do by recursively walking the tree of “Outcomes” Objects and moving them into a new flattened Array holding all of the nodes.

When saving the model, you will need to do the reverse, constructing the “Outcomes” Arrays in the node objects based on the relationships between the Nodes.