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
Jackson does not include type info in fields #1015
Comments
The problem here is that So: to solve the problem, you would need to move |
Putting jsonTypeInfo to just interfaces serializes it as : {"@class":"Test$ConcreteB","a":{"@class":"Test$A"}} Notice that is marks the @Class value as interface type A. However, strangely, A alone gets serialized properly A a = new ConcreteA();
System.out.println(objectMapper.writeValueAsString(a)); as {"@class":"Test$ConcreteA"} I want to serialize and then deserialize objects which will hold different implementations of an interface. Thus concrete type info would be required for deserialization.(And hopefully can be used for deserialization) |
@akshay-sharma This is not enough to help: please include relevant class/interface definitions. |
It looks like I was facing problems due to innner classes I wrote for testing. I put public and static qualifier on these and are able to get the desired behavior now. Here is the modified test I began with case http://pastebin.com/4g84rsAd |
I am trying to serialize an object to json using jackson 2.6.3 I want to include type info in the serialized json. This does not work for members nested within this class.
Here is the test code.
The json being converted by jackson is
Note that it does not include type info for field 'a'. The type info does get included while serializing just A.
The text was updated successfully, but these errors were encountered: