Это моя структура json, которую я вывожу на консоль:
0:
ApplicationName: null
ApplicationsId: "024e5e4b-9afd-44af-be33-8cab3eb6ce8c"
CreatedOn: "2019-04-03T23:20:30.063584"
Path: ""
children: [{…}]
id: "a97620e2-690c-4c5d-9a53-4c4ef713156e"
parent: "#"
text: "main 1"
__proto__: Object
1:
ApplicationName: null
ApplicationsId: "024e5e4b-9afd-44af-be33-8cab3eb6ce8c"
CreatedOn: "2019-04-03T23:20:36.0979761"
Path: ""
children: []
id: "993f86eb-df13-40ea-a519-263bb844ee43"
parent: "#"
text: "main 2"
__proto__: Object
2:
ApplicationName: null
ApplicationsId: "024e5e4b-9afd-44af-be33-8cab3eb6ce8c"
CreatedOn: "2019-04-03T23:20:36.1190942"
Path: ""
children: [{…}]
id: "fe0aeaad-468d-4482-856a-b87273df4b80"
parent: "#"
text: "main 3"
__proto__: Object
3:
ApplicationName: null
ApplicationsId: "024e5e4b-9afd-44af-be33-8cab3eb6ce8c"
CreatedOn: "2019-04-03T23:20:36.1238693"
Path: ""
children: [{…}]
id: "279931ad-e89c-4056-b0bc-7be41339baba"
parent: "#"
text: "main 4"
__proto__: Object
Я пытаюсь загрузить его в jstree, но получаю сообщение об ошибке:
не может прочитать свойство 'id' из undefined в parse_flat
Вот как я объявляю мое jstree на данный момент:
$("#tree").jstree({
'core': {
'data': {
"url": "@Url.Action("DisplayChildren", @ViewContext.RouteData.Values["controller"].ToString())",
"dataType":"json"
}
}
});
Это вызываемый контроллер:
[HttpGet]
[Route("Repositories/Repositories/DisplayChildren")]
public JsonResult DisplayChildren()
{
var output = repositoriesData.GetChildren("");
return Json(output);
}
Я что-то упустил? Я уже изменил имена некоторых объектов, и у всех дочерних объектов уже есть парентида.
РЕДАКТИРОВАТЬ:
Я добавил JSON.stringify, чтобы посмотреть, смогу ли я преобразовать вывод. Ошибка исчезла, но на экране ничего не отображается. Консоль показывает это, хотя:
[{"id":"a97620e2-690c-4c5d-9a53-4c4ef713156e","parent":"#","text":"main 1","ApplicationName":null,"ApplicationsId":"024e5e4b-9afd-44af-be33-8cab3eb6ce8c","Path":"","CreatedOn":"2019-04-03T23:20:30.063584","children":[{"id":"f3e0a4aa-f466-455d-b102-c79e62775e63","parent":"a97620e2-690c-4c5d-9a53-4c4ef713156e","text":"main 1 - sub 1","ApplicationName":null,"ApplicationsId":"024e5e4b-9afd-44af-be33-8cab3eb6ce8c","Path":"","CreatedOn":"2019-04-03T23:20:36.1176032","children":[]}]},{"id":"993f86eb-df13-40ea-a519-263bb844ee43","parent":"#","text":"main 2","ApplicationName":null,"ApplicationsId":"024e5e4b-9afd-44af-be33-8cab3eb6ce8c","Path":"","CreatedOn":"2019-04-03T23:20:36.0979761","children":[]},{"id":"fe0aeaad-468d-4482-856a-b87273df4b80","parent":"#","text":"main 3","ApplicationName":null,"ApplicationsId":"024e5e4b-9afd-44af-be33-8cab3eb6ce8c","Path":"","CreatedOn":"2019-04-03T23:20:36.1190942","children":[{"id":"aa230395-0731-48ff-824d-304237c34034","parent":"fe0aeaad-468d-4482-856a-b87273df4b80","text":"main 3 - sub 1","ApplicationName":null,"ApplicationsId":"024e5e4b-9afd-44af-be33-8cab3eb6ce8c","Path":"","CreatedOn":"2019-04-03T23:20:36.1206852","children":[{"id":"0b16f5f2-032a-43d6-8b24-ac4368d86c5e","parent":"aa230395-0731-48ff-824d-304237c34034","text":"main 3 - sub 1 - subsub 1","ApplicationName":null,"ApplicationsId":"024e5e4b-9afd-44af-be33-8cab3eb6ce8c","Path":"","CreatedOn":"2019-04-03T23:20:36.1223118","children":[]}]}]},{"id":"279931ad-e89c-4056-b0bc-7be41339baba","parent":"#","text":"main 4","ApplicationName":null,"ApplicationsId":"024e5e4b-9afd-44af-be33-8cab3eb6ce8c","Path":"","CreatedOn":"2019-04-03T23:20:36.1238693","children":[{"id":"95a31a4b-6bf1-47b3-91e0-2ffddd4deec1","parent":"279931ad-e89c-4056-b0bc-7be41339baba","text":"main 4 - sub 1","ApplicationName":null,"ApplicationsId":"024e5e4b-9afd-44af-be33-8cab3eb6ce8c","Path":"","CreatedOn":"2019-04-03T23:20:36.1255852","children":[]}]}]