I want to extract multiple values pk
, code
, type.toStr
(which type
is nested) from the following JSON using JsonPath:
{
"items": [{
"pk": "000a1236",
"code": "10023",
"type": {
"toStr": "report",
...
},
...
}, {
"pk": "00a1ef09",
"code": "20141",
"type": {
"toStr": "complaint",
...
},
...
},
...
]
}
I'm using JsonPath library and my attempts:
- Using
type.toStr
(result: no output):- JsonPath:
$.items[*]['pk','code','type.toStr']
- Output:
[{pk=000a1236, code=10023}, {pk=00a1ef09, code=20141}]
- JsonPath:
- Using
type
(result: other fields oftype
are included too):- JsonPath:
$.items[*]['pk','code','type']
- Output:
[{pk=000a1236, code=10023, type={toStr=report, ...}}, {pk=00a1ef09, code=20141 type={toStr=complaint, ...}}]
- JsonPath:
Is there any way to extract pk
, code
and type.toStr
together (with single JsonPath) without including other type
fields?