-
-
Notifications
You must be signed in to change notification settings - Fork 221
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
MismatchedInputException
when reading field with same name as class
#433
Comments
MismatchedInputException
when reading field with same name as class
One quick note: for tests, one should not use |
Yes, I can reproduce this issue, and using just Jackson annotations as well (so unlikely to be issue wrt JAXB annotation mapping. |
Wait, no: test I had was wrong and after fixing mismatch with name: first XML sample is wrong and XML must be: <Product>
<Prices>
<Price>
<Start>50</Start>
<Price>2.53</Price>
<End>99</End>
</Price>
</Prices>
</Product> and that does work with 2.12.0-rc2. |
@cowtowncoder, thanks for your quick support. The Price field must be the last element of the Price object (according the XSD), not the second as you've mentioned in your comment. Side note, I know using the "fail on unknown properties" is a bad practice, we use it to skip a lot of fields in the source data we receive. I should have left it out of my example, but it doesn't really change the failing outcome. |
@petervandenbroek ah. Changing of ordering was accidental: I think I was playing with order during testing and had forgotten to revert it back. Thank you for pointing it out. At this point (2.12.0-rc2) ordering does not seem to cause issues any more -- this makes sense as the handling of "wrapping" (or lack thereof) was rewritten for 2.12 to work reliably. About the only thing I can see that is different (and that I missed) is used of If you can still reproduce this with 2.12.0-rc2 feel free to reopen. |
|
Ticket #393 has been fixed in that a Jackson annotated class can be read if a nested field with the same name as the class is found.
However, when the class is generated from an XSD and thus has JAXB annotations, this still seems to fail.
For example, this XML should now be read correctly:
We've created an XSD based on this and generated models from it.
The generated classes look like this:
(for readability and relevance, I've removed the "generated" annotation and unrelated comments.)
Lastly, this is how the XmlMapper is created:
When creating a simple test that creates an object to write and read again, it fails during the reading.
The test:
The exception:
com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of
java.math.BigDecimalout of START_OBJECT token at [Source: (ByteArrayInputStream); line: 15, column: 7] (through reference chain: package.Product["Prices"]->package.Prices["Price"]->java.util.ArrayList[0]->package.Price["Price"])
There is a way around this problem and that is to move the "price" field as first element of the "price" object.
But as you might expect, I have no influence on the input data here..
The text was updated successfully, but these errors were encountered: