Constructing JSON issue

I have tried a lot of methods to achieve the following and I might be missing something so if someone knows how to achieve this json structure from a flat file.
The contact section is easy but the fieldvalues I cannot figure out. Help!
{
“contact”: {
“email”: "johndoe@example.com",
“firstName”: “John”,
“lastName”: “Doe”,
“phone”: “7223224241”,
“fieldValues”:[
{
“field”:“1”,
“value”:“The Value for First Field”
},
{
“field”:“6”,
“value”:“2008-01-20”
}
]
}
}

Welcome to the Community, Cris!

The trick here is to use “Unpivot”. By unpivoting, we put the row data into two columns: field, and values. Then constructing fieldValues is trivial using the “Construct JSON” action.

See the example below:

construct-json.morph (4.5 KB)

For multiple rows, enumerate rows using the “Enumerate rows” action. Then use the row numbers for grouping in “Unpivot” and “Construct JSON”.