-
-
Notifications
You must be signed in to change notification settings - Fork 227
XML to Json serialization is not mapping the data properly #229
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
Comments
I get the same kind of thing from this. Not only does it not build a JSON array as it should, it completely loses the top level tag.
By the way I am using Java 8 and have the following libraries: core 2.8.8 Do I have a library mismatch perhaps? |
This issue still exists with 2.9.3. I'm trying to migrate from json.org to jackson and the output of the conversion is incomplete. |
Code works exactly as expected; there will not be "fixes". I will explain why.
From this I would strongly suggest that attempts to directly convert between XML and JSON using Tree Model is a bad idea. It is fine to convert from XML to POJO to JSON, or vice versa -- this will retain enough metadata to allow for proper conceptual conversion. |
The problem is the json.org library does the conversion successfully in the examples I'm working with but the license isn't usable on our project and all the stack overflow posts point to Jackson as the only alternative. XLST is an alternative but i've been trying to avoid going down that path. |
@absolutesantaja one common case where things get wrong quickly is the case of "one element is Object; two or more repeated is Array" logic. This usually causes problems by converting what should be 1-value into Object/Map. But as to converting from logic used by One thing that could be done for Jackson 3.0 -- and I'll make note of this as an idea -- would be to have separate XML Tree Model ( Since it seems there is a lot of demand for something like this I think it should be tackled in some form for Jackson 3.x. It is tricky challenge due to JSON/XML data model impedance... but worth tackling I think. |
I'd like to add that
Does not solve existing problem. We have problem here that might be hard to solve due to technical problems, but take perspective of end-user using this library. Now, what solution do I have right now, without studying intrinsics of Jackson and this XML extension for it? |
I prepared small Kotlin library to overcome problems mentioned in this issue. It offers naive implementation to overcome problem with missing root tag and it maps multiple child elements with the same name into a array. |
I land up with the same scenario today. It would be great if we have any workaround or solution for this usecase. I cant fall back from Jackson because the amount of work i put to use this high. Thanks in advance. |
As things are, I will close this as "work as intended" just because
|
For what it is worth, this ultimately became #403 which is (2) from above: it will be included in 2.12.0. |
I have some list months in the row tags in a XML format. But while mapping the data to Json it is not mapping properly. Please check below for the reference.
The output for the above code is:
The text was updated successfully, but these errors were encountered: