简体   繁体   中英

Pojo to Pojo Transformation using DataWeave

I am trying to use DataWeave for Pojo to Pojo transformation. This works fine but the output is always a LinkedHashMap. I tried coercing this to an object but still get the same output. Is there a way to seamlessly convert the LinkedHashMap to the desired Pojo representation?

Use the 'class' metadata key as hint for what class needs to be created and sent in. If this is not explicitly defined, DataWeave will try to infer from the context or it will assign it the default values, HashMap and ArrayList:

%dw 1.0
%output application/java
---
{
    id: "xxx"
} as :object{
    class : "com.test.Product"
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM