慕标8209245
2020-05-19 10:38
观察以下JSON数据结构,设计Node类和⼯具⽅法 Node NodeUtils.getNode(List<Node> n odes, String path) ,通过该⽅法可以获取nodes中的Node.path与输⼊参数path相同的节点。 [ { "path": "level0_0/", "value": "value", "children": [ { "path": "level0_0/level1_0/", "value": "value", "children": [ { "path": "level0_0/level1_0/level2_0", "value": "value", "children": [] },{ "path": "level0_0/level1_0/level2_1", "value": "value", "children": [] },{ "path": "level0_0/level1_0/level2_1", "value": "value", "children": [] 3 |} ] },{ "path": "level0_0/level1_1/", "value": "value", "children": [ { "path": "level0_0/level1_1/level2_0", "value": "value", "children": [] },{ "path": "level0_0/level1_1/level2_1", "value": "value", "children": [] },{ "path": "level0_0/level1_1/level2_1", "value": "value", "children": [] } ] } ] },{ "path": "level0_1/", "value": "avaluerg", "children": [] } ] 实现效果(伪代码) List<Node> nodes = JSON.parse(str); Node node = NodeUtils.getNode(nodes, "level0_0/level1_1/level2_1"); print(JSON.toString(node)); //运行结果 { "path": "level0_0/level1_1/level2_1", "value": "value", "children": [] }
还没有人回答问题,可以看看其他问题
Java数据结构与排序算法快速入门
2667 学习 · 11 问题