I have a JSONPath expression that is matching the expected node. But I want to return a property of the parent of that node.
Here is the source 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"
}
]
}
Here is the JSONPath Expression: $.recordList[.customFieldList[?(@.value.name=='JEANS')]]
and it returns the following match:
[
{
"value": {
"name": "JEANS",
"internalId": "44",
"typeId": "91"
},
"internalId": "933",
"scriptId": "custrecord_size_range",
"_typeName": "SelectCustomFieldRef"
}
]
However, what I want to return is the .internalId property of the PARENT element that contains the customFieldList
array from which the above element got matched.
How do I need to change my JSONPath Expression to return the indicated parent property?