Currently, there is no way to specify different merge behaviors for array-like types and Maps if one of the types is used as a container and the other one for the nested items. If either a ConfigOverride for merging is set for the type of the container class or @JsonMerge is set directly on the container property, the merge behavior for the container type is always applied to its items as well.
Expected behavior
ConfigOverrides should apply to container items as long as there is no other config with precedence.
Example (List inside Map)
class SomePojo {
Map<String, List<Integer>> someMap;
}
// serialization config
ObjectMapper mapper = new ObjectMapper();
mapper.setDefaultMergeable(false); // default
mapper.configOverride(Map.class).setMergeable(true);
mapper.configOverride(List.class).setMergeable(false); // this has no effect for Lists inside Maps
Expected result:
{"someMap: {"list": [1, 2, 3]}} + {"someMap: {"list": [4, 5, 6]}} => {"someMap: {"list": [4, 5, 6]}}
Actual result:
{"someMap: {"list": [1, 2, 3]}} + {"someMap: {"list": [4, 5, 6]}} => {"someMap: {"list": [1, 2, 3, 4, 5, 6]}}
The override for List is not applied to nested items. Merging is still enabled for the them despite of using configOverride(List.class).setMergeable(false).
Test case
https://github.com/dgerhardt/test-case-jackson-jsonmerge/blob/master/src/test/java/JacksonJsonMergeNested.java
Related discussion
https://gitter.im/FasterXML/jackson-databind?at=60e6fef482dd9050f5dd3008
Currently, there is no way to specify different merge behaviors for array-like types and
Maps if one of the types is used as a container and the other one for the nested items. If either aConfigOverridefor merging is set for the type of the container class or@JsonMergeis set directly on the container property, the merge behavior for the container type is always applied to its items as well.Expected behavior
ConfigOverrides should apply to container items as long as there is no other config with precedence.Example (List inside Map)
Expected result:
{"someMap: {"list": [1, 2, 3]}}+{"someMap: {"list": [4, 5, 6]}}=>{"someMap: {"list": [4, 5, 6]}}Actual result:
{"someMap: {"list": [1, 2, 3]}}+{"someMap: {"list": [4, 5, 6]}}=>{"someMap: {"list": [1, 2, 3, 4, 5, 6]}}The override for
Listis not applied to nested items. Merging is still enabled for the them despite of usingconfigOverride(List.class).setMergeable(false).Test case
https://github.com/dgerhardt/test-case-jackson-jsonmerge/blob/master/src/test/java/JacksonJsonMergeNested.java
Related discussion
https://gitter.im/FasterXML/jackson-databind?at=60e6fef482dd9050f5dd3008