gsingam
3 years agoOccasional 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"
},
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