Skip to main content

I want to create HashMap where key will be one filed and value will be whole object. Sample input is

 

{"Location": [{

"startDate": "1900-01-01T00:00:00",

"Code": "9001",

"abc": "text1"

},

{

"startDate": "1900-01-01T00:00:00",

"Code": "9002",

"abc" : "text2"

}]

}

 

Desired output with key as "Code" filed and value as whole location object. Is there any way to achieve this using dataweave. I have tried following but it produces array instead of HashMap.

 

%dw 1.0

%output application/java

---

location: payload.location map {

($.Code) : $

}

7 answers
  1. Jun 10, 2016, 9:14 AM

    Thanks.. It worked for me.

0/9000