This example will show how to convert the "Field1" and "Field2" fields into arrays within existing JSON data.
Example Input Values
{
"statusCode" : 200,
"statusDescription" : "OK",
"numRows" : 1,
"data" : [ {
"data" : {
"Field1" : "content1",
"Field2" : "content2",
"Field3" : 1,
"Field4" : "content3",
"Field5" : "content4",
"NewField": "test"
}
} ],
"elapsedTime" : 1,
"errors" : [ ]
}
CODE
JOLT Transformation Code
[
{
"operation": "cardinality",
"spec": {
"data": {
"*": {
"data": {
"Field1": "MANY"
}
}
}
}
},
{
"operation": "cardinality",
"spec": {
"data": {
"*": {
"data": {
"Field2": "MANY"
}
}
}
}
}
CODE
Example Output Values
{
"statusCode" : 200,
"statusDescription" : "OK",
"numRows" : 1,
"data" : [ {
"data" : {
"Field1" : [ "content1" ],
"Field2" : [ "content2" ],
"Field3" : 1,
"Field4" : "content3",
"Field5" : "content4",
"NewField" : "test"
}
} ],
"elapsedTime" : 1,
"errors" : [ ]
}
CODE