Search code examples
javamuleanypoint-studiodataweave

How to Convert hashmap into proper json format in mule 4?


I am trying to log my hashmap it looks something like this : enter image description here

How do I convert it into proper json format ?


Solution

  • You can use the Transform Component and write the dataweave code as follows:

    %dw 2.0
    output application/json
    ---
    payload pluck(message,property,index) -> {(index) :{(property) :message}}
    

    This should work.