У меня есть приложение ASP.NET WebAPI, которое отправляет клиенту json-ответы Javascript.Избегайте отправки json-свойства
У меня есть класс, который я использую, чтобы построить древовидную:
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; }
}
я должен скрывать от моего Json
ответа на children
свойство, когда этот элемент не имеет детей, а также скрыть cls
и expanded
Недвижимость.
я должен получить что-то вроде этого:
[{
"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
}]
},
Любой ключ?