Hello everyone! I have a problem with serialization via Jackson.
When i do JsonNode smth = readValueToTree(obj) I get information about 
class type (e.g. java.Math.BigInteger, java.lang.ArrayList). This problem 
pop up for entities contains Map<String, Object> without any serializer. 
Also in entity which is not full filled. E.g. I have class ContactMethod 
which contains several fields. If all information is present then problem 
goes away. But if filled only one field with id (type bigInteger) then i 
catch class type info:
Expected:

"contactMethods": [
"@type": "PhoneNumber",
"id": "9148293419813662646",

Actual:

"contactMethods": ["java.util.ArrayList", 
"@type": "PhoneNumber",
"id": "9148293419813662646"

Another example (with map serialization):
My class have chars (Map<String, Object>). Expected, that when I'll 
serialize it I'll get:

"chars": { "char": [ 1 ] },

but actual I get:

"chars": {"char": ["java.math.BigInteger", 1]}

Anyone knows why it happens? Thanks


I got the answer like:

>From symptoms it looks like you have enabled "default typing" (there are 
multiple methods in ObjectMapper to do that), which forces inclusion of 
type information similar to what happens when you use @JsonTypeInfo
 annotation.
You will want to disable this setting, or use explicit @JsonTypeInfo(use = 
Id.NONE) to disable polymorphic handling for specific field(s).


But,  I have enabled "default typing" and @jsontypeinfo(use = Id.CLASS), I 
need it in the other reasons.

This problem appears strangely:

[image: problem]

Birthday and contactMethods are located under contacts.
But if contactMethods is located in the first level like contacts - all is 
ok

[image: problem2]

-- 
You received this message because you are subscribed to the Google Groups 
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jackson-user+unsubscr...@googlegroups.com.
To post to this group, send email to jackson-user@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to