-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for xpath and xml attr. via @ #66
Comments
This would definitely need actual description of what is desired: title is quite ambiguous. |
I updated the description with an example of what I'm trying to do, I see for Json one option is JsonPath https://github.com/json-path/JsonPath |
Maybe https://cassiomolin.com/2016/07/13/using-jackson-and-json-pointer-to-query-and-parse-an-arbitrary-json-node/ is worth a read. If you Google Jackson and JSON pointer or Path, you will find lots of existing solutions. |
I'm able to read json, but I need to keep the node since the structure is arbitrary |
My main issue is that XPath is strongly XML-specific, ditto for attributes. It will not be usable for things other than XML, since concept of attributes (f.ex) are XML-isms. But it does sound like this would be specific for Jackson XML format module (jackson-dataformat-xml), where it may or may not make sense. Jackson does not handle XML as DOM nodes, for example; and all logical manipulation occurs via streams of At the same time, adding something to decorate attributes with |
As long as there is some xml attribute syntax it would suffice since json and xml have their own mapper |
For suggestions for features to add to XML module, an issue would need to be created at |
Side note: what is currently the way to do node.at("/a/b").asText() for that xml? |
The original case is not something Jackson supports, due to name collision (or, rather, I think both attribute But if there was a feature to use
for attribute and
for element. |
Okay, I'll open the issue soon then, thanks |
Filed as: FasterXML/jackson-dataformat-xml#573 so closing this one. |
In a project we're trying to interpret either Json or XML depending on what the user gives as entry data, along with some paths to the document.
We're using Jackson and the dataformat-xml and choose the mapper via a flag, but the path syntax doesn't seem to allow grabbing attributes with @, like in xpath syntax, example:
xml = "<a b=\"attrib\"><b>node</b></a>"
and as path:
"/a/@b"
for the attribute and"/a/b"
for the nodeThe text was updated successfully, but these errors were encountered: