Javascript json值的jstree出现了一些错误

Javascript json值的jstree出现了一些错误,javascript,json,jstree,Javascript,Json,Jstree,我的Json: [{"id":1,"text":"ungrouped","icon":"/icons/Group_16x16.png", "parent":0,"dashboard":null,"childrenList":null}] 我的jS: // ajax demo $('#ajax_topo').jstree({ 'core' : { 'data' : { 'url' : './topology.json'

我的Json:

[{"id":1,"text":"ungrouped","icon":"/icons/Group_16x16.png",  
  "parent":0,"dashboard":null,"childrenList":null}]
我的jS:

// ajax demo

    $('#ajax_topo').jstree({
        'core' : {
          'data' : {
            'url' : './topology.json',
            'data' : function (node) {
              return { 'id' : node.id };
            }
          }
        }
    });
我的Html:

<h1>AJAX Topology demo</h1>
<div id="ajax_topo" class="demo"></div>
AJAX拓扑演示
我明白了

错误:未捕获类型错误:无法读取未定义的属性“children”


这是一个Json数组。因此,您必须对其应用索引

节点.id
替换为
节点[0]。id

$('#ajax_topo').jstree({
        'core' : {
          'data' : {
            'url' : './topology.json',
            'data' : function (node) {
              return { 'id' : node[0].id };
            }
          }
        }
    });

这是一个Json数组。因此,您必须对其应用索引

节点.id
替换为
节点[0]。id

$('#ajax_topo').jstree({
        'core' : {
          'data' : {
            'url' : './topology.json',
            'data' : function (node) {
              return { 'id' : node[0].id };
            }
          }
        }
    });