Jackson 3 migration guide for BasicPolymorphicTypeValidator #316
Replies: 5 comments 4 replies
-
|
PRs for https://github.com/FasterXML/jackson/blob/main/jackson3/MIGRATING_TO_JACKSON_3.md are much appreciated |
Beta Was this translation helpful? Give feedback.
-
|
Thank you @wgroeneveld -- these were indeed gaps in the migration guide. And probably something many users will encounter, so you are saving everyone a lots of time and effort. |
Beta Was this translation helpful? Give feedback.
-
|
@cowtowncoder, @brainbaking — FYI, I ran into issues with serialization/deserialization when using Jackson 3 for caching purposes. Even after following the guidelines from section "ObjectMapper: automatic inclusion of type information configuration", I was not able to get it working correctly for It seems that type information is not preserved properly, which makes deserialization fail (or produce incorrect results) for generic collection types. Minimal example: ObjectMapper mapper = JsonMapper.builder()
.activateDefaultTyping(...)
.build();
List<Foo> input = List.of(new Foo("bar"));
String json = mapper.writeValueAsString(input);
// expected: type info included
// actual: missing or insufficient type info
List<Foo> result = mapper.readValue(json, List.class); // fails or loses type infoAs a workaround, I ended up wrapping collections into dedicated single-field records: public record FooList(List<Foo> values) {}This works correctly with Jackson 3: FooList wrapper = new FooList(List.of(new Foo("bar")));
String json = mapper.writeValueAsString(wrapper);
FooList result = mapper.readValue(json, FooList.class);Is there something missing in the documentation regarding this use case, Happy to provide more details if needed. |
Beta Was this translation helpful? Give feedback.
-
|
@lukaszungier please do not add issue reports on random discussions. File an issue on jackson-databind. @JooHyukKim I suspect this is not about caching. |
Beta Was this translation helpful? Give feedback.
-
|
Thanks @cowtowncoder, I'll prepare example and create new issue. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all,
We are working towards making our async background job processor library compatible with Jackson 3 (see jobrunr/jobrunr#1415) and encountered more than a few problems-no wait, challenges-during the process.
The biggest problem we had is the lack of proper documentation: the migration guide did not cover our specific quirks. For example, we relied on
LaissezFaireSubTypeValidatorthat suddenly became inaccessible (not covered in the guide) so I had to learn how to use theBasicPolymorphicTypeValidator.builder()(also not there?)Do you folks accept a PR to help improve said guide?
Thanks!
Cheers,
Wouter
Beta Was this translation helpful? Give feedback.
All reactions