-
Notifications
You must be signed in to change notification settings - Fork 116
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
Xml cannot read in Optional.empty #280
Comments
Intent with Jackson XML module is that it should be able to read what it writes: so the XML structure created with Package does not necessarily allow mapping different kinds of XML representations. |
Then this should be a bug. I tried reading back what it writes. It's readable, but the deserialized object is different from the original one. Here is the code:
The test is failing. And I checked "test-jackson.xml" and "deserialized-test-jackson.xml". They are indeed different. The former is just
but the later one is
Could you fix this bug? I would appreciate it! |
That sounds like a bug then. Unfortunately I doubt I have time to tackle this issue at this point. But if you or anyone else has time and interest, I can help get PR reviewed and so on. One practical challenge here is that of testing, as the issue requires both XML module and JDK 8 datatype module -- neither of which should have dependency to the other. But I think same problem would affect use of |
Do you have an idea on how to fix it? I looked at your OptionalDeserializer, looks like it should deserialize to |
A major problem is that empty XML element can mean either "empty" value (like "" for One way to force "null-ness" is to add <!-- NOTE: xmlns:xsi could be declared in parent to avoid using multiple times
-->
<MyObject2>
<MyObject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
</MyObject2> |
Ok, so, above
after which things work. I don't see a working way to solve this problem in other way but I suggest you try this. |
I have an object
then another object with an optional field of the object above
I serialize MyObject2 as
I got
I'm assuming a single
<xxx/>
denotes optional empty? Is this correct?Assume it is correct, I deserialize it as
But then I found the deserialized one is not Optional.empty. It seems to call the default constructor of MyObject so it has a = 1 in it. Do you know how should I actually deserialize Optional.empty?
The text was updated successfully, but these errors were encountered: