Merging for arrays does mean concatenation (append for Collections), and nothing else. This because while there are many possible ways users might want to handle merging of two sequence values, it is surprisingly difficult to figure out declarative way that covers enough without being very complicated.
So: instead of trying to figure out a complex solution that might not cover all cases, I went with simple, predictable solution, which does not cover all cases. In future it could be possible to extend `@JsonMerge` to perhaps allow custom handler of some sort that would allow custom logic, but this does not yet exist. -+ Tatu +- On Fri, Oct 26, 2018 at 3:32 PM Dzmitry Sankouski <eqwewqdasdsaczx...@gmail.com> wrote: > > I have two Jsons I want to merge. Arrays in json should be also merged, not > concatenated. > > Example: > Json 1: > { > "level1": { > "value": "a", > "anotherValue": "z", > "array1": [ > { > "value": "b", > "anotherValue": "z" > } > ] > } > } > > > Json 2: > { > "level1": { > "value": "c", > "array1": [ > { > "value": "d" > } > ] > } > } > > After merge, I want to get: > { > "level1": { > "value": "c", > "anotherValue": "z", > "array1": [ > { > "value": "d", > "anotherValue": "z" > } > ] > } > } > > > Using code from this suggestion about json merge, I got array1 not merged, > but concatenated: > { > "level1": { > "value": "c", > "anotherValue": "z", > "array1": [ > { > "value": "b", > "anotherValue": "z" > }, > { > "value": "d", > "anotherValue": "z" > } > ] > } > } > > > How do I achieve arrays in json being merged, not concatenated? > > -- > 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 jackson-user+unsubscr...@googlegroups.com. > To post to this group, send email to jackson-user@googlegroups.com. > 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 jackson-user+unsubscr...@googlegroups.com. To post to this group, send email to jackson-user@googlegroups.com. For more options, visit https://groups.google.com/d/optout.