Forum Discussion

srini_polimera's avatar
srini_polimera
New Contributor III
3 years ago

Map input array issue

array mapping in mapper

My json:
“Employee”:
[
{
“name”: “Tom Cruise”,
“name”: “Robert Downey Jr.”
}
]

I need Output

{
“item”:
[
{
“name”: “Tom Cruise”,
“age”: 50,
},
{
“name”: “Robert Downey Jr.”,
“age”: 50,
}
]
}

Could you please help. Age is constant here.

Thanks

1 Reply

  • Hello @srini.polimera,

    You can try with Mapper and with the following expression.

    $Employee.map(x => x.extend({"age":50}))
    

    I suppose that you have employees as separate objects in the array, and not as you have them here in the input.

    Let me know if this helps you.

    BR,
    Aleksandar.