Concat array of objects into a single object


#1

With a quite complex LET clause I have an array similar to this one:

"fields": [
  {
	"EVT_DATE": "01-02-2018 - 10:59",
	"EVT_DATE_VALUE": "01-02-2018 - 10:59",
	"EVT_DATE_VDO": ""
  },
  {
	"EVT_URGENCE": "non",
	"EVT_URGENCE_VALUE": false,
	"EVT_URGENCE_VDO": ""
  },
  {
	"EVT_NC_AC": "Nouveau cas",
	"EVT_NC_AC_VALUE": "Nouveau cas",
	"EVT_NC_AC_VDO": "VDO_NC"
  }
]

I would like to transform this array into a single object that would have all the properties of each of its belonging child. Something like this:

{
	"EVT_DATE": "01-02-2018 - 10:59",
	"EVT_DATE_VALUE": "01-02-2018 - 10:59",
	"EVT_DATE_VDO": "",
	"EVT_URGENCE": "non",
	"EVT_URGENCE_VALUE": false,
	"EVT_URGENCE_VDO": "",
	"EVT_NC_AC": "NC",
	"EVT_NC_AC_VALUE": "NC",
	"EVT_NC_AC_VDO": "VDO_NC"
}

How can I manage to have this result? I tried somethings with ARRAY_FLATTEN and I saw the different OBJECT Functions but didn’t manage to get it working.

Thanks for any help!


#2

OBJECT v.name:v.val FOR v IN OBJECT_INNER_PAIRS(fields[*]) END