I have a json as below
{
"Shop": [
{
"id": "1",
"Items": [
{
"Item": "Item1"
}
]
},
{
"id": "2",
"Items": [
{
"Item": "Item2"
}
]
},
{
"id": "3",
"Items": [
{
"Item": "Item3"
}
]
}
]
}
I would like to select all Items with just JsonPath. I have tried as following combinations but I did not get any values
$.[Shop[0], Shop[1], Shop[2]].Items
$.[Shop[0].Items, Shop[1].Items, Shop[2].Items]
Thank you in advance
If I understand correctly you are looking for * wildcard to select all elements in an array:
$.Shop[*].Items
Gives me:
[ [ { "Item": "Item1" } ], [ { "Item": "Item2" } ], [ { "Item": "Item3" } ] ]
Using jsonpath-cli:
$.Shop[*].Items[*]
gives
[{"Item":"Item1"},{"Item":"Item2"},{"Item":"Item3"}]
Alternatively,
$.Shop[*].Items.['Item']
gives
["Item1","Item2","Item3"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With