I worked a bit on this, and what happens here is that the nominal type in question is actually `Object.class` (value type of `Map`). It is not (2.9.0.pr4) possible to prevent merging at one of 2 levels:
1. Global baseline: ObjectMapper.setDefaultMergeable(false); // unless overridden by type, property 2. Type default: ObjectMapper.configOverrides(Object.class).setMergeable(false) Unfortunately there really isn't a good way to do such shallow copy on per-call basis (from API perspective "readerForDeepUpdating" vs "readerForShallowUpdating" would make sense) -- this is technically unfeasible at this point. -+ Tatu +- On Sun, May 14, 2017 at 9:33 PM, <[email protected]> wrote: > I tried with mapper.configOverride(List.class).setMergeable(Boolean.FALSE); > > It seems not working. > > On Friday, May 12, 2017 at 4:01:14 PM UTC+9:30, Tatu Saloranta wrote: >> >> On Thu, May 11, 2017 at 10:20 PM, <[email protected]> wrote: >>> >>> Dears, >>> >>> I just upgrade to 2.9.0.pr3 for our project because we need the feature >>> of merge a json string to update an existing object or hashmap. >>> >>> I tested readerForUpdating works now by default deep merge the data in >>> json string to an existing nested hashmap now, which is what we need. >>> >>> But we don't want deep merge the lists, let's say here is a json >>> {"array":[{"stringInput":"aString"}]}, and the existing HashMap already have >>> the list, we think in most scenario, replacing list/array makes sense than >>> merging them. >>> >>> I guess the current implementation is to merge list as well by default as >>> part of the deep merge. >>> >>> So how to replace list instead of deep merge? >>> >> >> At this point I think that would require a custom deserializer. Which >> deserializer to replace depends on type of Map that contains it: if it's >> declared as something like `Map<String, Object>`, that would be the >> "untyped" deserializer, one registered for type Object.class. >> >> In theory, use of configOverrides() might work, a la: >> >> mapper.configOverride(List.class).setMergeable(Boolean.FALSE); >> >> but I am not sure if that is honored... perhaps that's worth checking come >> to think of it. >> Perhaps this could go under >> >> https://github.com/FasterXML/jackson-databind/issues/1625 >> >> -+ Tatu +- >> > > -- > You received this message because you are subscribed to the Google Groups > "jackson-user" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "jackson-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. For more options, visit https://groups.google.com/d/optout.
