Convert an array to an object

Hi,

I need to convert via N1QL an array that is part of a document into an object.
Example, I have that:
{
“myobj”: [
{
“1”: {
“field1”: true,
“field2”: 0
}
},
{
“34”: {
“field1”: false,
“field2”: 1000
}
},
{
“10”: {
“field1”: true,
“field2”: 21
}
}
]
}

and the final document I need is like that one:
{
“myobj”: {
“1”: {
“field1”: true,
“field2”: 0
},
“34”: {
“field1”: false,
“field2”: 1000
},
“10”: {
“field1”: true,
“field2”: 21
}
}
}

I have tried to use object_concat with each position of the original array, but id does not work and I am unable to find the correct syntax to get the final outcome I need.

Could any of you help me with thtat?
Thanks!

You can just index the array. Repeat as many times as the maximum of the array.

{
  "myobj": [
    {
      "1": {
        "f1": "a",
        "f2": "b"
      }
    },
    {
      "14": {
        "f1": "x",
        "f2": "y"
      }
    }
  ]
}


select bucket.myobj[0].*, bucket.myobj[1].*, bucket.myobj[2].* from ...
[
  {
    "1": {
      "f1": "a",
      "f2": "b"
    },
    "14": {
      "f1": "x",
      "f2": "y"
    }
  }
]
WITH doc AS ({ "myobj": [ { "1": { "f1": "a", "f2": "b" } }, { "14": { "f1": "x", "f2": "y" } } ] })
SELECT OBJECT o.name:o.val 
       FOR o IN (SELECT RAW u2 
                 FROM d.myobj AS u1 
                 UNNEST OBJECT_PAIRS(u1) AS u2) 
       END AS myobj
FROM doc AS d;