how to use Jsonpath to set values with a customized function for nested JSON objects the JSON objects is nested by unordered json array and json object such as
{
"store": {
"name": "ABC Co",
"book": [
{
"category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": 8.95,
"edition": {
"year": 1990,
"published_by": "MacMillan"
}
},
{
"category": "fiction",
"author": "Evelyn Waugh",
"title": "Sword of Honour",
"price": 12.99,
"edition": {
"year": 1980,
"published_by": "MacMillan"
}
}
]
}
}
give any JsonPath such as
$.store.book[0:].price
(jsonarray)
$.store.name
(jsonobject)
I want to use my own customized function such as encrypt function to process all the value matched by the provided jsonpath
Do any JsonPath package or library provide the function? Or how could I write the setNestedJson(String jsonPath, function func)
sincerely thanks for help!
I use com.alibaba.fastjson2.JSONPath
, but it may be not able to set value with function.
for example
JSONPath.set(jsonobject, "$.store.book[0:].price", "test")
I wonder how to deal it with function