1

Input

{
  "Ids": ["1","2","3"]
}

Output

["Ids": "1", "Ids": "2", "Ids": "3"]

1 Answer 1

1

Use the map() function to map each element. Note that each element in the output array is an object, which in JSON is represented between curly brackets.

%dw 2.0
output application/json
---
payload.Ids map {ids: $}

Output:

[
  {
    "ids": "1"
  },
  {
    "ids": "2"
  },
  {
    "ids": "3"
  }
]
Sign up to request clarification or add additional context in comments.

4 Comments

Isn't there a way just to have "ids": "1" and not have them enclosed in an object? ["ids": "1", "ids" : "2", "ids": "3"] ?
That doesn't make sense in JSON at least. What are you trying to do with the output?
No, man I think I got you, my bad! Thanks :D, the broader use case is to call a salesforce query the number of times there are Ids, so if there are 5 ids in the array , then the same sf query should be called 5 times with those 5 individual ids. So was trying to use a parallel for each for it.
If you are using it with the Salesforce Connector you'll want to use application/java instead of JSON. If you print the output you will see represented similar to JSON but in memory they are Java lists and maps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.