0
votes

I need to construct a json object like below

{ "Name":"Tom", "Hobbies":["Fishing","Reading"],"Cars": [{"Make":"Honda","Model":"Civic","Price":"25000"},{"Make":"Toyota","Model":"Camry","Price":"20000"}]

I am constructing this JSON object in a Java transformer. I am get this value [{"Make":"Honda","Model":"Civic","Price":"25000"},{"Make":"Toyota","Model":"Camry","Price":"20000"}] from DB query. But when I try to add this as JSON array in the transformer, it's throwing string can't be casted as JSON Array. Please let me know how to go about it.

1
can you show you dw transformation?Satheesh Kumar

1 Answers

0
votes

Just use transform message activity with snippet below.

%dw 1.0 %output application/json


{ Name: "Tom", Hobbies: ["Fishing","Reading"], Cars : payload }