I am using some json path to update name references in fields and it is working great. Now we want a similar thing to return the references. I am trying to modify the same json paths to return the parent items. I am having issues when the matching is not on the same level as the object.
Example JSON Path (This works to update the value)
$.LogicNodeList[*].compChildren[?(@.diagramName == 'S-DGN-B')].diagramName
I want the logicNodeList (this gives an error not liking the '?')
$.LogicNodeList[?(@.compChildren[?(@.diagramName == 'S-DGN-B')])]
Example JSON
{
"LogicNodeList": [
{
"id": "b61aa8a5-8edd-4207-ab58-ccba83afe67e",
"name": "CCS_TOP",
"desc": "",
"gateType": "gtOr",
"rootName": "CCS_TOP",
"compChildren": [],
"gateChildren": [
"CCS-Trains",
"CCS-Supply"
],
"isRoot": true
},
{
"id": "27865e6f-b457-42ff-9303-11c700657212",
"name": "CCS-Supply",
"desc": "",
"gateType": "gtOr",
"rootName": "CCS_TOP",
"compChildren": [
{
"diagramName": "S-DGN-B",
"stateValues": []
},
{
"diagramName": "C-MOV-1",
"stateValues": []
},
{
"diagramName": "S-TNK-T1",
"stateValues": []
}
],
"gateChildren": [],
"isRoot": false
},
{
"id": "6d366c22-5e48-45b5-ac5d-9325a122e451",
"name": "CCS-Train-A",
"desc": "",
"gateType": "gtOr",
"rootName": "CCS_TOP",
"compChildren": [
{
"diagramName": "C-PMP-A",
"stateValues": []
},
{
"diagramName": "S-DGN-A",
"stateValues": []
},
{
"diagramName": "C-CKV-A",
"stateValues": []
},
{
"diagramName": "C-MOV-A",
"stateValues": []
}
],
"gateChildren": [],
"isRoot": false
}]
}
I want the json path to return
[{
"id": "27865e6f-b457-42ff-9303-11c700657212",
"name": "CCS-Supply",
"desc": "",
"gateType": "gtOr",
"rootName": "CCS_TOP",
"compChildren": [
{
"diagramName": "S-DGN-B",
"stateValues": []
},
{
"diagramName": "C-MOV-1",
"stateValues": []
},
{
"diagramName": "S-TNK-T1",
"stateValues": []
}
],
"gateChildren": [],
"isRoot": false
}]
i hope you are using C#, (IMHO) otherwise please let me know and i will remove this answer so, why not to select by isroot=false? you will get all children