Deep Object Merge

Is it possible to do a deep object merge with n1ql? I don’t really care about array values, I just want to combine multiple objects together where it only overrides the deepest value. A recursive object agg basically.

inputs:

{
   "a" : {
      "b": {
          "c": true
       }
   }
}

{
   "a" : {
      "c": {
          "f": true
       }
   }
}

{
   "a" : {
      "b": {
          "e": false
       }
   }
}

result:

{
   "a" : {
      "b": {
          "c": true,
          "e": false
       },
       "c": {
        "f": true
       }
   }
}

N1QL has OBJECT construction but not Deep Object Merge.

Ya, that’s not quite what I would need. I don’t really know the shape of the objects. I just want to merge them together.

1 Like