Hi,
I want to put a json object inside one cell in a CSV file. For ex,
{
name: "mule",
address: {
"state":"xxxx",
"country":"yyyy"
}
}
Now I want to insert this into CSV with two columns (name, address) and entire address object should get inserted under address column.
Please help on achieving this using Dataweave 2.0
HI @Ramkumar K ,
When you are going to transform, use the following script:
%dw 2.0
output application/csv quoteValues=true
var data = {
state: "xxxx",
country: "yyyy"
}
---
[
{ a: 'a',
b: 'b',
c: write(data, 'application/json')
},
{ a: 'a',
b: 'b',
c: write(data, 'application/json')
}
]
Later, whenever you wants to read the data from csv, then use the following metadata:
Some Screenshots for your reff:
- My first transform to store JSON into CSV.
- Now check my second transform where I tried to read the csv and convert it to JSON using the metadata mentioned in the first pic.
Regards,
Lalit Panwar
- My first transform to store JSON into CSV.