@JsonIgnoreProperties(ignoreUnknown = true)
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE,
getterVisibility = JsonAutoDetect.Visibility.NONE,
setterVisibility = JsonAutoDetect.Visibility.NONE,
isGetterVisibility = JsonAutoDetect.Visibility.NONE)
And that only has @JsonProperty on the getters, what is supposed to be the expected serialization/deserialization behaviour? What about:
ObjectMapper objectMapper = new ObjectMapper();
System.out.println("Json Serialize");
String string = objectMapper.writeValueAsString(new MyModelClass2(
1L, "Foo", "Bar", new Date(), "Baz", new Date(), "Bal", "Bo", "Bo"
));
System.out.println(string);
System.out.println("Json Deserialize");
System.out.println(objectMapper.readValue(string, MyModelClass2.class));
Has the following output:
Json Serialize {"createdDate":1476429800628,"someNumber":1,"someCondition":"Bo","someName":"Foo"} Json Deserialize MyModelClass2{createdBy='null', createdDate=Fri Oct 14 09:23:20 CEST 2016, someNumber=1, updatedBy='null', updatedDate=null, someCondition='Bo', firstName='null', someName='Foo'}
Which clearly shows that only the marked @JsonProperty properties are used for serialization/deserialization. It provides the same output when using @JsonGetter instead of @JsonProperty. This seems conflicting with the sentences in the javadoc:
JsonProperty
annotation (which was introduced in version 1.1). Getter means that when serializing Object instance of class that has this method (possibly inherited from a super class), a call is made through the method, and return value will be serialized as value of the property.Marker annotation that can be used to define a non-static, single-argument method to be used as a "setter" for a logical property as an alternative to recommended JsonProperty
annotation (which was introduced in version 1.1).
Setter means that when a property with matching name is encountered in JSON content, this method will be used to set value of the property.
--
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+unsubscribe@googlegroups.com.
To post to this group, send email to jackso...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.