I have a ASP.NET WebAPI application that sends to the Javascript client json responses.
I have a class that I use to build a tree view:
public class TreeViewModel
{
public string text { get; set; }
public string cls { get; set; }
public bool expanded { get; set; }
[JsonProperty(PropertyName = "checked")]
public bool checked { get; set; }
public bool leaf { get; set; }
public List<TreeViewModel> children { get; set; }
}
I have to hide on my Json response the children property when that element doesn't have any children and also hide the cls and expanded property.
I should get something like this:
[{
"text": "To Do",
"cls": "folder",
"expanded": true,
"children": [{
"text": "Go jogging",
"leaf": true,
"checked": true
},{
"text": "Take a nap",
"leaf": true,
"checked": false
},{
"text": "Climb Everest",
"leaf": true,
"checked": false
}]
},
Any clue?