【发布时间】:2017-01-18 20:07:55
【问题描述】:
我正在尝试过滤其中 hasContent 属性为 true 且 legalStatutes 字符串数组包含带有“AIA”的字符串的 formParagraph 对象列表。问题是“AIA”在数组中并不总是处于零位置。
仅当“AIA”是数组中的第一项时,以下 JSONPath 才有效。
$.businessResponse.formParagraphList[ ? ((@.hasContent == true) && (@.legalStatutes[0] == 'AIA'))] {
"rbacUser": null,
"businessResponse": {
"formParagraphList": [{
"id": 1261,
"hasContent": true,
"legalStatutes": [
"Pre_AIA",
"AIA"
]
},
{
"id": 67,
"hasContent": true,
"legalStatutes": [
"AIA",
"Pre_AIA"
]
},
{
"id": 68,
"hasContent": true,
"legalStatutes": [
"Pre_AIA"
]
}
]
}
}
有没有办法使用 JSONPath 在不知道它的索引的情况下检查 JSON 对象内的字符串数组中是否存在特定字符串?
【问题讨论】: