user3378513 February 2016

Convert a Treeview to JSON using C#

I have to convert a Treeview object to JSON using C#. I am currently using JsonConvert.SerializeObject().

public class SubTreeNode : TreeNode
{
    public CustomProperties customProperties;
}

public class CustomProperties {

    public string property1 = "Property1";
    public string property2 = "Property2";
    public string property3 = "Property3";
}

When tried with JsonConvert.SerializeObject(treeView1.Nodes); It only gives top nodes...not getting the child nodes, sub-child & so on.

What is the easiest way to Serialize and deserialize this Treeview object. Thanks a million in advance!

Answers


Igor Ĺ evo February 2016

You will need to add methods that produce JSON from each node recursively.

Check out the related post: Serializing a Tree into Json Object.

Post Status

Asked in February 2016
Viewed 1,953 times
Voted 7
Answered 1 times

Search




Leave an answer