I have two arrays and need to convert these arrays into a single object array using jolt.
Input
"Name": ["Test Test", "Test2 Test"]
"email": ["Test@tesasds.com", "Test2@test.com"]
output
[{"Name":"Test Test","email":"Test@tesasds.com"},{"Name":"Test2 Test","email":"Test2@test.com"}]
Description inline:
[
{
"operation": "shift",
"spec": {
// for every key
"*": {
// and every item in the array
"*": {
// create a structure <index of array> : key : value
// This will therefore join the two because the indexes will be the same
"@": "&.&2"
}
}
}
},
{
//Remove the index as key
"operation": "shift",
"spec": {
"*": "[]"
}
}
]
I'd suggest running the first shift to get understanding of the description.