我有如下所示的 JSON。我想获取 Attribute.Name/Attribute.content 对,其中 Name.Text[?(@.content == 'All-Inclusive Mgmt')]
我想过类似的事情
Attribute[?(@.Name.Text.content == 'All-Inclusive Mgmt']
可能有效..但是当(我使用 Java Jayway JSONPath)时失败
有人可以帮忙吗?如果可能的话,这必须是纯 JSONPath
{
"Attribute":[
{"Name":
{"Text":[
{"content":"All-Inclusive Mgmt","Language":"ENG"},
{"content":"??????","Language":"ZHT"}
]},
"Value":
{"Text":
[{"content":"?","Language":"ZHT"},
{"content":"Yes","Language":"ENG"},
{"content":"Oui","Language":"FRE"},
{"content":"Si","Language":"ITL"},
{"content":"Si","Language":"SPN"},
{"content":"Ja","Language":"GER"},
{"content":"??","Language":"JPN"}
]
}
},
{"Name":
{"Text":[
{"content":"All-Inclusive Fees","Language":"ENG"},
{"content":"??????","Language":"ZHT"}
]},
"Value":
{"Text":
[{"content":"?","Language":"ZHT"},
{"content":"Yes","Language":"ENG"},
{"content":"Oui","Language":"FRE"},
{"content":"Si","Language":"ITL"},
{"content":"Si","Language":"SPN"},
{"content":"Ja","Language":"GER"},
{"content":"??","Language":"JPN"}
]
}
}
]
}
最佳答案
这条路在这里
$.Attribute[*].Name.Text[?(@.content=='All-Inclusive Mgmt')]
给你
{
"content":"All-Inclusive Mgmt",
"Language":"ENG"
}
这是All-Inclusive Mgmt 的值(value)内容
关于java - 使用 JSONPath 根据深度搜索的结果查找 JSON 对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49554569/