Modify deepMerge behavior on arrays
See original GitHub issueAt present, when one runs deepMerge
on 2 arrays, only the argument contents remains in the resulting array, the contents of calling array is lost:
import io.circe.Json, io.circe.literal._
val a1: Json = json"""[{"id": 1}, {"id": 2}, {"id": 3}]"""
val a2: Json = json"""[{"id": 4}, {"id": 5}, {"id": 6}]"""
a1.deepMerge(a2)
res4: Json = [{"id" : 4}, {"id" : 5}, {"id" : 6}]
This behavior is documented. However, could we consider changing it for arrays, and make it do the simple concatenation, like [{"id": 1}, {"id": 2}, {"id": 3}, {"id" : 4}, {"id" : 5}, {"id" : 6}]
? I’d say, the current behavior is not completely intuitive.
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
deepmerge - npm
Merging creates a new object, so that neither x or y is modified. Note: By default, arrays are merged by concatenating them.
Read more >How to deep merge instead of shallow merge? - Stack Overflow
Performs a deep merge of objects and returns new object. Does not modify * objects (immutable) and merges arrays via concatenation.
Read more >Creating and editing data - Puppet
A deep merge combines the keys and values of any number of hashes to return a merged hash. It contains an array of...
Read more >Data Deep Merge — Eleventy
mergewith to combine Arrays and deep merge Objects, rather than a simple top-level merge using Object.assign . Read more at Issue #147. As...
Read more >Lodash Documentation
Arguments. array (Array): The array to modify. values (Array): The values to remove. ... are iterated like arrays. To avoid this behavior use...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
A concatenation mode could be useful
Any reason why #1275 was closed and not merged? This would be super useful