Could you please help me writing JOLT spec for the following?
Input JSON:
{
"a": "1",
"b": "2",
"c": "3",
"d": "4"
}
I need to get output:
{
"columns": ["a","b","c","d"],
"data": [[1,2,3,4]]
}
You can use the shift transformation below :
[
{
"operation": "shift",
"spec": {
"*": {
"$": "columns",
"@": "data[0]"
}
}
}
]
If the elements of the data array must strictly be of type integer, then a modify-overwrite-beta transformation needed too, such as
[
{
"operation": "modify-overwrite-beta",
"spec": {
"*": "=toInteger"
}
},
{
"operation": "shift",
"spec": {
"*": {
"$": "columns",
"@": "data[0]"
}
}
}
]