Let's say I have this .json on witch I want to apply a function that round up the price of the book:
{
"store": {
"book": [
{
"category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": 8.95
},
{
"category": "fiction",
"author": "Evelyn Waugh",
"title": "Sword of Honour",
"price": 12.99
},
{
"category": "fiction",
"author": "Herman Melville",
"title": "Moby Dick",
"isbn": "0-553-21311-3",
"price": 8.99
},
{
"category": "fiction",
"author": "J. R. R. Tolkien",
"title": "The Lord of the Rings",
"isbn": "0-395-19395-8",
"price": 22.99
}
],
"bicycle": {
"color": "red",
"price": 19.95
}
},
"expensive": 10
}
The idea I had for doing that was to specify the jsonpath
$.store.book[*].price
and get in return the list of ouput path (like on this website: https://jsonpath.com/ )
[ "$.store.book[0].price", "$.store.book[1].price", "$.store.book[2].price", "$.store.book[3].price" ]
or even better a direct mapping between the path and the value
[ {"$.store.book[0].price":8.95}, {"$.store.book[1].price":12.99}, {"$.store.book[2].price":8.99}, {"$.store.book[3].price":22.99} ]
and then making a loop over the list to apply the function on each value and setting the json with the new value
But i can't find how to get that list of path, how can i do that ? (or if you have something to directly replace the value by a function of themselves, i would take it too :) )
PS: the .json I give is just an example, I need it for .json way more nested than that