I'm trying to convert the field-value mapping from CSV to Json format,below code is my dataweave code for mapping the fields from CSV and converting it into Json format:
%dw 1.0
%output application/json
---
{
"volume":
[
payload groupBy $.StartDate map ((val,cal) ->
{
StartDate:val.StartDate[0],
rows :
[
{
AccountID : val.AccountID,
ProductID : val.ProductID,
Value : val.Value
}
]
}
)
]
}
Iam getting output as below :-
{
"volume": [
[
{
"StartDate": "8/1/2016",
"AccountID": [
"16482965",
"16482966"
],
"ProductID": [
"12235398476-AR02",
"12235398477-AR03"
],
"Value": [
"1720",
"1722"
]
},
.
.
.
But i want my output to look like below :
{
"volume": [
[
{
"StartDate": "8/1/2016",
"AccountID":"16482965","ProductID":"12235398476-AR02","Value":"1720",
"AccountID":"16482966","ProductID":"12235398477-AR03","Value": "1722"
},
.
.
.
Can anybody please here?
AccountID,ProductIDandValue. I guess you meant to have one field forStartDateand an array of structures, each structure like one of the records (containing AccountID, ProductID and Value). - FDavidov