Skip to content

Add support for @JsonMerge to allow "deep update"  #1399

@cowtowncoder

Description

@cowtowncoder

Currently existing values of properties are not taken into consideration, with the rare case of "setterless-getters" where this is done for Collection types if no setter exists.
But it would be useful to allow this for Maps and POJOs as well.

Proposed mechanism is to allow use of:

public class POJO {
    @JsonSetter(merge=OptBoolean.TRUE)
    public List<String> names = new ArrayList<>();
    {
         names.add("first");
    }

In addition to per-property annotation, it should also be possible to specify "config overrides" using:

objectMapper.configOverrides(MyPOJO.class)
     .setter(JsonSetter.Value.from(.....));

which would specify default merge/no-merge settings for properties of specified type.
It would probably also make sense to allow setting fully global default, similar to ability to set "serializationInclusion" global defaults (with JsonInclude.Value).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions