-
-
Notifications
You must be signed in to change notification settings - Fork 222
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
XmlMapper
not deserializing root-level Enums
#121
Comments
My first suggestion would actually be to always use a (JSON) Object as the root value, and not try to serialize "bare" Lists, arrays, Maps or Enums as root value. This avoid many of the problems. But let me see what is the issue here: the only problem with |
Interesting. I can reproduce the issue, and there was no test for this case. So upside is that this is not a known problem (which often means "more difficult to fix") but rather "as of yet unknown". I'll add a unit test, see what gives. Thank you for reporting this! |
Hmmh. Ok, this may be tricky to handle. Problem is with structural impedance between XML, JSON, and that the fix at parser/databinder level relies on POJO properties to allow defining element contents as scalars. Will add a test, at any rate. |
Thanks a lot for your comments yesterday. That cleared up what was going on. |
Ok no problem. We can still try to make that work in future; but for now at least this is documented (I added a note on README) |
XmlMapper
not deserializing root-level Enums
Turns out I can finally fix this for 2.12, now that "extract scalar from Object" logic can be plugged in. |
I want to deserialize XML using XmlMapper so that it is as mechanically similar to how we deserialize JSON. I'm doing something wrong when it comes to enums, however. Below is my enum definition and my test code.
This prints out this:
JSON serialized string: "MALE"
JSON deserialized enum: MALE
XML serialized string: MALE
and it throws a
JsonMappingException
at theXmlMapper
readValue()
method, saying it can not deserialize instance of SimpleEnum out of START_OBJECT token.I do not get this error when write a class that has an enum as a member.
The text was updated successfully, but these errors were encountered: