我有一个与预期节点匹配的 JSONPath 表达式。但我想返回该节点父节点的属性。
这是源json:
{
"totalRecords": 2,
"totalRecordsSpecified": true,
"recordList": [
{
"name": "34-34",
"customFieldList": [
{
"value": {
"name": "PANTS",
"internalId": "46",
"typeId": "91"
},
"internalId": "933",
"scriptId": "custrecord_size_range",
"_typeName": "SelectCustomFieldRef"
}
],
"internalId": "343",
"_typeName": "CustomRecord"
},
{
"name": "34-34",
"customFieldList": [
{
"value": {
"name": "JEANS",
"internalId": "44",
"typeId": "91"
},
"internalId": "933",
"scriptId": "custrecord_size_range",
"_typeName": "SelectCustomFieldRef"
}
],
"internalId": "321",
"_typeName": "CustomRecord"
}
]
}
这是 JSONPath 表达式:$.recordList[.customFieldList[?(@.value.name=='JEANS')]]
它返回以下匹配:
[
{
"value": {
"name": "JEANS",
"internalId": "44",
"typeId": "91"
},
"internalId": "933",
"scriptId": "custrecord_size_range",
"_typeName": "SelectCustomFieldRef"
}
]
但是,我要返回的是 PARENT 元素的 .internalId 属性,该属性包含customFieldList
与上述元素匹配的数组。
如何更改我的 JSONPath 表达式以返回指定的父属性?