Open dcolazin opened 1 year ago
Sorry, I don't understand your request. Could you explain more? Is it related to XPath or JsonPath?
Thank you for the fast reply. The request is an extension of the Josson.getNode(String)
method, which uses the map syntax. I'm mainly interested in JsonPath, but I would say the support with XPath is similar. Using the example in SO: given an object
{
"a": {"a1": 1, "a2": 2},
"b": foo,
"c": []
}
and a list of (json)paths ["$.a.a2", "$.c"]
the desired result is
{
"a": {"a2": 2},
"c": []
}
Currently, it is possible to obtain it with the map syntax in the following way josson.getNode("map(a.map(a2), c)")
, while the equivalent jsonpath syntax would be josson.getNode("$.a.a2", "$.c")
.
The purpose of a Josson path is to process along the path and query the last element value. For example, a.a2
returns 2
only, and removed the parent structure. I'm thinking of adding a new and special function build()
to retain the full path structure.
josson.getNode("build(a.a2, c)")
will produce
{
"a": {"a2": 2},
"c": []
}
Does it fulfill your requirement?
Following this Stackoverflow answer, I started experimenting with Josson. The map syntax is extremely useful, but xpath/jsonpath would be extremely useful.