-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Implement opt/get methods for accumulated values #551
Comments
Agreed that the XML transformation is a tradeoff, sometimes a bad one. But would prefer to see something like an XMLParserConfiguration with() option that lets the user customize parsing. Using opt() and get() methods to change the output from the internal representation doesn't seem like the best solution, at least to me. |
Can we add some customize rule In the process of converting xml to json? |
No objection to allowing developers to customize parsing. We already have XMLParserConfiguration, should try to use that first. |
My project is also heavily relies on the XML to JSON functionality of json.org, and it would be perfect if the |
We don't currently have any xpath support in the project, and I don't foresee us ever supporting XSD. However we do have a JSONPath implementation that could be used to implement something similar to your idea, but on the result side instead of the source side. |
@johnjaylward I guess your solution patches the JSONObject after the XML to JSON conversion. This is a good workaround, I should have thought about it :) , but I still would prefer if the framework could support. BTW, I am sorry that I mentioned XSD, I know it would be way too complex to use here ... |
Hi, is this issue still open? May I take it? Thank you! |
Hi, @914-Chu, assigning this issue to you. |
Thank you! |
It seems to me that the XmlParserConfiguration.forceList property added in #646 addresses this issue. If so, I will close it. Please let me know if you think work still needs to be done. |
Currently we have an
accumulate
method onJSONObject
, however, we don't have an easy way to get back out a consistent value (i.e. JSONArray).One area where this is most painful is in XML to JSON conversion where some XML documents may contain a single element, while other documents may contain many.
Example 1:
Example 2:
This currently leads to very messy code that has to check the type of value parsed:
It would be nice if there was a convenience function in the JSONObject to get values that are accumulated:
See also #550
The text was updated successfully, but these errors were encountered: