Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problem with `JsonTypeInfo.As.EXISTING_PROPERTY`, `@JsonValue`/`@JsonCreator` combination

See original GitHub issue

Looks like there is a regression in handling of polymorphic type that uses @JsonAnyGetter as well as EXISTING_PROPERTY` type id inclusion. Failing test was provided by @carterkozak via #2952.

NOTE: instead of @JsonAnyGetter it looks like the issue is rather with @JsonValue, TypeSerializer/TypeDeserializer access.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

cowtowncodercommented, Nov 25, 2020

@carterkozak glad to know you were able to figure out a setting that works in both cases, as I realize that this is quite complicated use case. I hope we are getting closer to getting things to work consistently so such changes to observed behavior are not needed. Thank you very much for reporting these issues!

One remaining possible challenge is the problem of duplicated properties for type ids – that is, TypeSerializer writing its entry but there also being a regular property with same name. I hope that could be resolved in 2.13.

cowtowncodercommented, Dec 1, 2020

As per above discussion I think the new behavior is expected one and what is defined as “works as expected” form 2.12 onwards. Closing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jackson @JsonValue is conflicting with @JsonTypeInfo
Try to set @JsonTypeInfo.include to JsonTypeInfo.As.EXISTING_PROPERTY @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.
Read more >
Inheritance in Jackson | Baeldung
This tutorial will demonstrate how to handle inclusion of subtype metadata and ignoring properties inherited from superclasses with Jackson.
Read more >
Jackson Json - @JsonTypeInfo, using Logical Type Name ...
Id.CLASS which causes fully-qualified Java class name to be serialized as the type identifier. Java class name may not be a good choice...
Read more >
Security update for jackson-databind, jackson-dataformats ...
As.EXISTING_PROPERTY + Can not deserialize json to enum value with Object-/Array-valued input, '@JsonCreator' + Fix to avoid problem with ...
Read more >
JsonSerialize, JsonTypeInfo not working, JsonAnyGetter ...
The @JsonCreator annotation can be used on constructors or factory methods for mapping incoming JSON properties to the constructor/factory method arguments.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found