
I need to add new line
example:
Request
{
"hello": {
"description": "success the request",
"extra": [
{
"key": "xyxyxxy",
"value": "2022.26.27"
},
{
"key": "szxzxzx",
"value": "sdus"
}
]
}
}
Excepted:
{
"Description": "success the request
xyxyxxy: 2022.26.27
szxzxzx:sdus"
}
@Carrie Donovan @Training: DataWeave 2.0 with Mule 4 @254 Mule Support @Abhishek Tiwari
Please help me on excepted format in DataWave
Hi Yashwanth,
Correcting your input
{
"hello": {
"description": "success the request",
"extra": [
{
"key": "xyxyxxy",
"value": "2022.26.27"
},
{
"key": "szxzxzx",
"value": "sdus"
}
]
}
}
Here is the code for this
%dw 2.0
output application/json
---
payload mapObject ((value, key, index) -> {
Description: value.description,
((extra: (value.extra map ((item, index) -> {
(item.key): item.value
}))reduce ((env, obj={}) -> obj ++ env)).extra)
})
Output--
Best,
Prathamesh K