You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By default, Jackson will try to construct a new property value Object, regardless of its type, and for POJO/Map/Collection types add contents into that new Object. The main alternative would be to first check if property already has a value, and if so, use that value instead.
Currently such "merge" approach can only be used for 2 cases:
For root value, via "updateValue()" for ObjectReader
For Map/Collection values, if (and only if!) there is no setter method (or visible field)
It seems, however, that the ability to specify "merge" as the default approach (but fall back to new Object in case property is null) would be useful. This could be supported via annotation; either a new one, or perhaps additional property to an existing one (@JsonProperty(valueCreation=CREATE/MERGE/MERGE_ONLY))... or ideally something better).
If this can be made to work on per-property basis, we could perhaps also consider ability to specify global default (alternative to "always create").
The text was updated successfully, but these errors were encountered:
cowtowncoder
changed the title
[2.8] Add support for "merge" annotation, to use existing POJO/Map/Collection property value
Add support for "merge" annotation, to use existing POJO/Map/Collection property value
Sep 30, 2016
By default, Jackson will try to construct a new property value Object, regardless of its type, and for POJO/Map/Collection types add contents into that new Object. The main alternative would be to first check if property already has a value, and if so, use that value instead.
Currently such "merge" approach can only be used for 2 cases:
ObjectReader
Map
/Collection
values, if (and only if!) there is no setter method (or visible field)It seems, however, that the ability to specify "merge" as the default approach (but fall back to new Object in case property is
null
) would be useful. This could be supported via annotation; either a new one, or perhaps additional property to an existing one (@JsonProperty(valueCreation=CREATE/MERGE/MERGE_ONLY))
... or ideally something better).If this can be made to work on per-property basis, we could perhaps also consider ability to specify global default (alternative to "always create").
The text was updated successfully, but these errors were encountered: