Skip to main content

Hello I am trying to transform this array :

[

{"a":"1",

"b":"2"},

{"a":"3",

"b":"4"},

{"a":"5",

"b":"6"}

]

into:

{"a":"1",

"b":"2",

"a":"3",

"b":"4",

"a":"5",

"b":"6"}

2 answers
  1. Mar 25, 2020, 9:00 AM

    @Arnaud Gohier​ you can try surrounding your array with braces {()}:

    %dw 2.0

    output application/json

    var a = [

    {

    "a": "1",

    "b": "2"

    },

    {

    "c": "3",

    "d": "4"

    },

    {

    "e": "5",

    "f": "6"

    }

    ]

    ---

    {(a)}

    output:

    {

    "a": "1",

    "b": "2",

    "c": "3",

    "d": "4",

    "e": "5",

    "f": "6"

    }

    Note: If you use the values specified in your example, this will result in invalid json (it will contain duplicate keys).

0/9000