Search code examples
muledataweavemulesoftmule4

Combine Result of flatten Function


How can I combine the result of a flatten function in Dataweave? I have the following payload:

[
  {
    "a": "hello"
  },
  {
    "b": "please"
  },
  {
    "c": "help"
  },
  {
    "d": "me!"
  }
]

and I want it to be like this:

[
  {
    "a": "hello",
    "b": "please",
    "c": "help",
    "d": "me!"
  }
]

I'm unable to figure out how to resolve this.


Solution

  • You can use Object destructor

    %dw 2.0
    output application/json
    ---
    [{(payload)}]