【发布时间】:2017-11-04 14:24:18
【问题描述】:
我正在尝试实现以下 json 很抱歉,但我不知道哪个是问题。
需要使用控制台的 JSON 屏幕截图:https://imgur.com/a/3HyI9
var requiredJson = {
chart: {
container: "#OrganiseChart-simple"
},
nodeStructure: {text:{name:"Root"},children:[{text:{name:"naresh"},children:[{text:{name:"rahul1"}},{text:{name:"rahul123"}},{text:{name:"kapil1"},children:[{text:{name:"priya12"},children:[{text:{name:"amit12"}}]}]}]},{text:{name:"roshan"}},{text:{name:"Seppl"}},{text:{name:"pankaj1910"}}]}
};
我的尝试:
我的尝试给了我这个结果:https://imgur.com/a/x1hot
当我使用回显到 json_encode($tree) 时,我的 php json :
[{"text":{"name":"Root"},"children":[{"text":{"name":"naresh"},"children":[{"text":{"name":"rahul1"}},{"text":{"name":"rahul123"}},{"text":{"name":"kapil1"},"children":[{"text":{"name":"priya12"},"children":[{"text":{"name":"amit12"}}]}]}]},{"text":{"name":"roshan"}},{"text":{"name":"Seppl"}},{"text":{"name":"pankaj1910"}}]}] ;
//$tree is a php array
var mytry = '<?php echo json_encode($tree); ?>';
var requiredJson = {
chart: {
container: "#OrganiseChart-simple"
},
nodeStructure: mytry
};
JS FIDDLE:https://jsfiddle.net/ueo0k9ys/1/
【问题讨论】:
标签: javascript php jquery arrays json