Search code examples
javajsonpath

Correct json Path


Please help me with correct json path. I am trying to extract "500" from "value".

Json (part of it) looks like this:

Vehicle {
"code": "BCA",
"name": "COLL",
"description": "Collision",
"limitTerms": [],
"deductibleTerms": [
{
"code": "qsw",
"name": "",
"value": "500",
"valueCode": "",
"valueDescription": "",
}
],
"otherTerms": [],
},

I want to use the name or description than reach to deductibleTerms and extract value from it.

I tried wrtting json path like that (which is for sure wrong)

"$.vehicle[description='Collision' and .deductibleTerms[*].value]"


Solution

  • The .deductibleTerms[*].value should not be inside the filter [] part of the expression since you are not filtering on it.

    $.vehicle[description='Collision'].deductibleTerms[*].value