Triumph Spitfire
Triumph Spitfire

Reputation: 645

Merge 2 or more arrays in single payload

This could be a very simple problem, but I'm not getting the desired output using dataweave 1.0. How can I merge multiple arrays (example below has only 2 arrays but it can be more) into a single object using dw 1.0?

//Input
    [
      {
        "value": [
          {
            "key1": 111,
            "val1": "AAA"
          },
          {
            "key1": 222,
            "val1": "BBB"
          }
        ]
      },
      {
        "value": [
          {
            "key1": 333,
            "val1": "CCC"
          }
        ]
      }
    ]

//Desired Output
{
  "value": [
    {
      "key1": 111,
      "val1": "AAA"
    },
    {
      "key1": 222,
      "val1": "BBB"
    },
    {
      "key1": 333,
      "val1": "CCC"
    }
  ]
}

Upvotes: 1

Views: 538

Answers (1)

Janardan Kelkar
Janardan Kelkar

Reputation: 170

value: flatten (payload.value)

Upvotes: 4

Related Questions