业务需要按照”response. customerInfo.children“来获取到每个 children 节点 list 并需要包含该节点的所有父节点及其属性(理论上好像只要在解析的时候将父节点传进来即可,因为子节点确定了那他的父节点肯定也是确定的,不存在 list 的问题),想了半天没有想出来,请各位大佬支支招!
原 json:
{
"response": {
"customerInfo": [
{
"uuid": "59a49249342f4262bd59ea2e36ac40d3",
"name": "张三",
"phoneNo": "15566669999",
"idCard": "123456789965412544545",
"wife": {
"uuid": "51e211b7d1e54578b0093a5418868aa6",
"name": "李四",
"phoneNo": "15566668888",
"idCard": "1236547896513245"
},
"children": [
{
"uuid": "8e1b40a3bc4a4f709a7076002132c7e3",
"name": "张五",
"phoneNo": "15523645896",
"idCard": "523641528965425"
},
{
"uuid": "cd73bd47b6a945e0b3ca86927a154c1b",
"name": "张六",
"phoneNo": "15562458952",
"idCard": "652154258962541"
}
]
},
{
"uuid": "c752f9ff5a0d4776880e8ea1f0fcc482",
"name": "王五",
"phoneNo": "13652366548",
"idCard": "123654856525665"
}
]
}
}
解析后需要得到的 list
[
{
"response": {
"customerInfo": {
"uuid": "59a49249342f4262bd59ea2e36ac40d3",
"name": "张三",
"phoneNo": "15566669999",
"idCard": "123456789965412544545",
"wife": {
"uuid": "51e211b7d1e54578b0093a5418868aa6",
"name": "李四",
"phoneNo": "15566668888",
"idCard": "1236547896513245"
},
"children": {
"uuid": "8e1b40a3bc4a4f709a7076002132c7e3",
"name": "张五",
"phoneNo": "15523645896",
"idCard": "523641528965425"
}
}
}
},
{
"response": {
"customerInfo": {
"uuid": "59a49249342f4262bd59ea2e36ac40d3",
"name": "张三",
"phoneNo": "15566669999",
"idCard": "123456789965412544545",
"wife": {
"uuid": "51e211b7d1e54578b0093a5418868aa6",
"name": "李四",
"phoneNo": "15566668888",
"idCard": "1236547896513245"
},
"children": {
"uuid": "cd73bd47b6a945e0b3ca86927a154c1b",
"name": "张六",
"phoneNo": "15562458952",
"idCard": "652154258962541"
}
}
}
}
]
就相当于是把每个子节点单独拿出来和他的各级父节点组成一个 JsonObject ,大佬们有没有什么妙招哇
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.