cancel
Showing results for 
Search instead for 
Did you mean: 

JSON Formatting

Ajay_Chawda
Contributor

Hello Experts,
Input :-
{
“column”: [
{
“name”: “firstName”
},
{
“name”: “lastName”
},
{
“name”: “middleName”
}
],
“content”: [
[
“aa”,
“bb”,
“cc”
],
[
“dd”,
“ee”,
“ff”
],
[
“oo”,
“pp”,
“qq”
]
]
}

Output :-
{
“data”: [
{
“firstName”: “aa”,
“lastName”: “bb”,
“middlename”: “cc”
},
{
“firstName”: “dd”,
“lastName”: “ee”,
“middlename”: “ff”
},
{
“firstName”: “oo”,
“lastName”: “pp”,
“middlename”: “qq”
}
]
}
can someone help me to achieve this without using scrip snap.

2 REPLIES 2

cjhoward18
Employee
Employee

Hi @Ajay_Chawda

Using a json Generator with your input document and a downstream mapper with this expression:
$content.map(row => row.toObject((elem, index) => $column[index].name))
Mapped to a target path: $data

produces your desired output.

@cjhoward18 thank you for help it worked like magic.