@JsonUnwrapped not supported for Map-valued properties
See original GitHub issueAccording to the documentation,
Annotation used to indicate that a property should be serialized “unwrapped”; that is, if it would be serialized as JSON Object, its properties are instead included as properties of its containing Object.
Unfortunately, this seems to work only with bean types, and does not work with Map<String, Object>
. Given that bean types are generally completely interchangeable with Maps, it would be very nice if this worked correctly.
Issue Analytics
- State:
- Created 11 years ago
- Reactions:23
- Comments:31 (15 by maintainers)
Top Results From Across the Web
Jackson JsonUnwrapped properties collision - Stack Overflow
When Outer objects are serialized - if inner is not null - Inner properties should be unwrapped, hence the @JsonUnwrapped usage.
Read more >Security update for jackson-databind, jackson ... - SUSE
An update that fixes three vulnerabilities is now available. Description: This update for jackson-databind, jackson-dataformats-binary, ...
Read more >FasterXML - Bountysource
@JsonUnwrapped not supported for Map-valued properties $ 0. Created 9 years ago in FasterXML/jackson-databind with 31 comments. According to the documentation,.
Read more >Jacksonでtop levelのpropertyを省略してMap<K, V>をserialize ...
で,どうすると良いかというと @JsonUnwrappedを使うという方法がまず考え ... ています: @JsonUnwrapped not supported for Map-valued properties ...
Read more >SUSE alert SUSE-SU-2022:1678-1 (jackson-databind ...
(bsc#1182481) Non security fixes: jackson-annotations - update from ... definitions for property + Deserialization Not Working Right with ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Unfortunately the @JsonAnyGetter does not work (easily) with Kotlin:
as the annotation needs to put on a method.
!! UPDATE !!
It does work (easily):
I have the same problem as @odrotbohm:
@JsonUnwrapped
sits on top of a generic. To get it to work, I’ve needed to create subclass that overrides the getter so I can add@JsonAnyGetter
. The any-getter doesn’t work because it’s of typeT
, not aMap
and it throws an error during runtime otherwise.This creates other problems because I’ve subclassed it. Being able to use
@JsonUnwrapped
would be much easier, cleaner and safer.