Skip to main content

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

10 个回答
  1. 2022年3月2日 07:24

    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--

    Hi Yashwanth, Correcting your input {Best,

    Prathamesh K

0/9000