Here it seems that you have an array of nodes, and each node has a rowset or another array of nodes, doesn't it? The first thing you could do is simply deserialize this to a List<object> as follows:
string treeData = "...";
This will turn your JSON into a list of objects, although you will need to manually find out what is (if each object is a string or a different List<object> ).
This usually helps to have some kind of class or structure to represent the "schema" for the data that you pass to the serializer, but this is a little more than the above.
In this case, you need your input as an actual JSON object, not just an array. Let's say you have this JSON (based on the above data):
{id: "root", children: [ {id: "881150024"}, {id: "881150024", children: [ {id: "994441819"}, {id: "881150024"}]}, {id: "-256163399"}, {id: "-256163399", children: [ {id: "-492694206"}, {id: "-256163399", children: [ {id: "1706814966"}, {id: "-256163399", children: [ {id: "-26481618"}, {id: "-256163399"}]} ]}]}]}
If you have a class like this:
public class Node { public String id; public List<Node> children; }
Then you can do something like:
string treeData = "...";
The code will be much easier to work with.
rusty source share