为了账号安全,请及时绑定邮箱和手机立即绑定

就是一个 Ztree 树用到的 json! 数据很多,没全部弄出来 格式大概就是这个样,请教怎么取?

就是一个 Ztree 树用到的 json! 数据很多,没全部弄出来 格式大概就是这个样,请教怎么取?

一只斗牛犬 2023-04-01 11:05:17
{"name": "DR", "value": "","id":"2","open": false,"icon": null,"children": [ {"name":"1","value":"", "id": "3", "open": false, "icon": null, "children": [ { "name": "1.1", "value": "","id":"4","open": false,"icon": null,"children": [ {"name":"1.1.1","value":"", "id": "5", "open": false, "icon": null, "children": [ { "name": "检查所见", "value": "1.1.1.1 内容", "id": "6", "open": false, "icon": null, "children": null, "target": "","pId": null,"url": null,"title": null}, {"name":" 诊断意见 ","value":"1.1.1.2 内容 ","id":"7","open": false,"icon": null,"children": null,"target":"", "pId": null, "url": null, "title": null } ], "target": "","pId": null,"url": null,"title": null } ],"target":"", "pId": null, "url": null, "title": null } ], "target": "","pId": null,"url": null,"title": null }, {"name":"2","value":"", "id": "8", "open": false, "icon": null, "children": [ { "name": "2.1", "value": "","id":"9","open": false,"icon": null,"children": [ {"name":"2.1.1","value":"", "id": "10", "open": false, "icon": null, "children": [ { "name": "检查所见", "value": "2.1.1.1 内容", "id": "11", "open": false, "icon": null, "children": null, "target": "","pId": null,"url": null,"title": null }, {"name":" 诊断意见 ","value":"2.1.1.2 内容 ","id":"12","open": false,"icon": null,"children": null,"target":"", "pId": null, "url": null, "title": null } ], "target": "","pId": null,"url": null,"title": null } ],"target":"", "pId": null, "url": null, "title": null } ], "target": "","pId": null,"url": null,"title": null } ],"target":"", "pId": null, "url": null, "title": null }  比如这段 json 我要根据 id 取到 value, 把 value 值传给前台弹出显示, 比如这段 json 里给后台传的 id 为 11,value 就是 2.1.1.1 内容 就这样
查看完整描述

2 回答

?
神不在的星期二

TA贡献1963条经验 获得超6个赞

你这个问题的关键不是如何解析JSON,而是取值方式不对。 

你传给后台的id是11,那就在后台只取出该条记录就可以了,为什么还要把整个树形结构的数据都返回来呢。


查看完整回答
反对 回复 2023-04-03
?
慕工程0101907

TA贡献1887条经验 获得超5个赞

第一,既然你已经把包含所有层级的json数据都拿出来,何必还要去调用服务器,直接利用js就可以展开显示了。第二,如果你想要点开一层再去服务器取出来显示,那就不需要一次拿出所有的层级数据,点某层级的展开再去取这一层的子集

查看完整回答
反对 回复 2023-04-03
  • 2 回答
  • 0 关注
  • 113 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信