On Mon, Jan 6, 2020 at 9:44 AM DGV wrote:
> Here is my SO post describing the problem i am facing.
>
> https://stackoverflow.com/questions/59602625/jackson-serialization-jsonproperty-conflicts-with-another-getter
>
> Details.
>
> I upgraded Spring 4.3 to Spring 5.2. The Jackson library also got upgraded
> from 2.8.3 to 2.10.
>
> I am experiencing the following problem with Serialization
>
> Currently (in 2.8.3) when i apply the JsonView "D.class" and serialize
> SubClass.java, i see "title" as a json property in the response. After
> upgrading to 2.10, I do not see "title" in the reponse. It seems like it
> does not like the fact that there is a getter method in the SuperClass as
> getTitle. If i change the JsonProperty from "title" to "title1", it works.
> I am now wondering how it worked fine in Jackson 2.8.3. Could it be
> possible that the JsonView (D. class) is not getting applied properly in
> 2.10 causing Jackson to see both the getter Methods as a conflict?
>
>
>
> public class SuperClass {
>
> @JsonView({A.class, B.class})
> public String getTitle(){}
> }
>
> public class SubClass extends SuperClass {
>
> @JsonView({A.class, B.class, C.class, D.class})
> @JsonProperty("title")
> public String getArticleTitle(){}
> }
>
>
>
This could be a bug, since resolving the case is bit complicated from
Jackson perspective -- after all, not only does it need to resolve all
annotations throughout inheritance hierarchy (which JDK itself won't do),
merge them from different accessors (getter/setter/field), but also handle
case of renaming as done here to associate accessors in 2 dimensions.
Changes to logic handling this processing are made to fix other found
issues but occasionally there can be regressions for cases that are not
tested, such as this one.
But one more thing that is needed would be actual code used for
serialization, to know for sure how ObjectWriter (or, if possible,
ObjectMapper directly?) is used for writing.
-+ Tatu +-
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/jackson-user/CAGrxA27aAN75OniP9NQFqFrL06rrTnRZ6mDEJY9UAvcshAqFRw%40mail.gmail.com.