-
-
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
No String-argument constructor/factory method to deserialize from String value when it is a Integer #254
Comments
With quick glance I agree, it seems like your use case should work. Problem probably comes from nesting involved. One thing on troubleshooting is that it is usually good idea to keep Thank you for reporting this issue. I hope to look into it soon. |
Ohh. I think I know the problem here: there is no way to link creator (constructor) property and backing
Couple of ways to make this working are:
In either case, constructor will not be used, and downside I guess is that it is not possible to make field There is still something strange about interaction with |
@cowtowncoder I tried with the recommendations what still not working, any other way to make it works? |
Note to self: problem is the fact that XML has no notion of values other than Strings (and nesting via elements, attributes), so Jackson just sees a String token and does not like that -- while there is coercion from Strings to numbers this only works for simple values but not delegation model. But it would be reasonable to support such usage for non-typed formats like XML (and CSV as well), if I can figure out a clean way to achieve that. |
I still get error on jackson-dataformat-xml-2.12.0-rc1, the xml I want to parse xml like |
I am trying to deserialise the following xml into the objects:
My classes are the following
My mapper dependencies are the following:
Here is the failing test with exception being thrown by the xmlMapper
From reading the exception it looks like the mapper is treating the value 28 as a string rather than a Integer but if i change the Bar class to the following and add an attribute to element bar to the raw xml the same test passes.
I would say that the Mapper should infer the type from the constructor parameter type and try to instantiate that object with the string value and under the hood do something like Integer.valueOf("28")
The text was updated successfully, but these errors were encountered: