Skip to main content

Mule Dataweave - Converting XML to JSON Arrayunble to convert xml to json array in dataweave 2.0

 

output :

"employees":{

"employee":{

"name" : "abc"

},

"employee":{

"name" : "xyz"

}

}

 

expected output :

"employees":{

"employee" : [

{ "name" : "abc" },

{ "name" : "xyz" }

]

 

dataweave script :

 

%dw 2.0

output application/json

---

payload

 

5 answers
  1. Jan 11, 2019, 5:08 PM

    Hi @tejakkk ,

     

    Could you try using next?

     

    %dw 2.0

    output application/java

    ---

    {"employees":{

    "employee":

    (payload.employees.*employee map{

    "name":$.name

    } )

    }

    }

     

    I hope the above helps! If you have any doubt do not hesitate to contact me.

     

    Regards,

     

    Arianna Flores

0/9000