Sri Rockz
Sri Rockz

Reputation: 85

How to convert object to array in dataweave

How to convert object to array in dataweave and i can say i want to remove that curly braces from input

Input:

{    
  "Person": [    
    "sri",    
    "123456",    
    "India"    
  ]    
}

Expected Output

[
  "sri",
  "123456",
  "India" 
]

Upvotes: 1

Views: 4579

Answers (1)

aled
aled

Reputation: 25812

Assuming a JSON output, it is not valid to have a key (ie "Person":) without being inside an object.

If you are only interested only in the contents of the array then you can use the DataWeave expression payload.Person which will return ["sri", "123456","India"], which is a valid array in JSON.

Upvotes: 5

Related Questions