Labs - JSON PATH - Introduction - KodeKloud
Expected output should be like this
[
"car",
"bike"
]
Instead of specifying the fixed index as below, is there any flexible way to pick up the element of 1st one & last one in the list?
alpine-host ~ ➜ cat q13.json | jpath ‘$[0,3]’
[
“car”,
“bike”
]
It seems below jpath query doesn’t meet the requirement:
alpine-host ~ ➜ cat q13.json | jpath ‘$[0,-1]’
[
“car”
]
Source file:
alpine-host ~ ➜ cat q13.json
[
“car”,
“bus”,
“truck”,
“bike”
]