user3095976
user3095976

Reputation: 135

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?

Upvotes: 2

Views: 1538

Answers (1)

Ryan Carter
Ryan Carter

Reputation: 11606

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

Upvotes: 3

Related Questions