Reputation: 1
Input:
{
"count": 3,
"employees":
[
{
"name":"appy",
"age":34
},
{
"name":"happy",
"age":38
},
{
"name":"cruise",
"age":36
}
]
}
Output:
[
{
"first":"appy",
"age":34
},
{
"first":"happy",
"age":38
},
{
"first":"cruise",
"age":36
}
]
This is my input i am trying to add "first" in "name" how can i do any suggestions i am using Map function here.
"first" in "name" place i am trying to use map function
Upvotes: 0
Views: 98
Reputation: 25872
Just map the elements:
%dw 2.0
output application/json
---
payload.employees map {
first: $.name,
age: $.age
}
Output:
[
{
"first": "appy",
"age": 34
},
{
"first": "happy",
"age": 38
},
{
"first": "cruise",
"age": 36
}
]
Upvotes: 1