Ask a Question

How to match the json sibling using expression

SOLVED
gsingam
Occasional Contributor

How to match the json sibling using expression

"Criteria" : [
{
"selectionCriteriaType" : "DEFENSE_REASONS",
"selectionCriteriaValue" : "AdditionalInformation"
},
{
"selectionCriteriaType" : "AVS_RESULT",
"selectionCriteriaValue" : "A"
},
{
"selectionCriteriaType" : "REFUND_STATE",
"selectionCriteriaValue" : "false"
},
{
"selectionCriteriaType" : "BILLING_ADDRESS",
"selectionCriteriaValue" : "false"
}

 

]

 

Above Json can be very huge and order of the elements  always changes. What would be my regular expression to match 

{
"selectionCriteriaType" : "REFUND_STATE",
"selectionCriteriaValue" : "false"
},

2 REPLIES 2
KarelHusa
Super Contributor

@gsingam,

I would use the following expression:

 

$.Criteria[?(@.selectionCriteriaType=="REFUND_STATE" && @.selectionCriteriaValue=="false")]

 

Please note your boolean elements are represented as strings now ("false" instead of false). I would recommend to fix it.

 

Best regards,

Karel

 

Karel@apimate.eu
https://apimate.eu
gsingam
Occasional Contributor

Thank you very much. You and your solution is awesome.

cancel
Showing results for 
Search instead for 
Did you mean: