In this example, it will be demonstrated how to add the key expression if it is not present in the existing JSON data.
Sample Original Message
{
"statusCode" : 200,
"statusDescription" : "OK",
"numRows" : 1,
"data" : [ {
"data" : {
"Field" : "content1",
"Field2" : "content2",
"Field3" : 1,
"Field4" : "content3",
"Field5" : "content4",
"NewlyAddedField": 12
}
} ],
"elapsedTime" : 1,
"errors" : [ ]
}
CODE
JOLT Code
[
{
"operation": "modify-default-beta",
"spec": {
"data": {
"*": {
"data": {
"NewlyAddedField": null,
"NewlyAddedField2": null
}
}
}
}
}
]
CODE
Sample Result Message
{
"statusCode" : 200,
"statusDescription" : "OK",
"numRows" : 1,
"data" : [ {
"data" : {
"Field" : "content1",
"Field2" : "content2",
"Field3" : 1,
"Field4" : "content3",
"Field5" : "content4",
"NewlyAddedField" : 12,
"NewlyAddedField2" : null
}
} ],
"elapsedTime" : 1,
"errors" : [ ]
}
CODE