Input JSON is
{
"name": "XYZ",
"fields": [
{
"Code": "8000385",
"Number": "9010005790",
"docDate": "19-05-2022",
"dueDate": "30-09-2022",
"totValue": "209121.66",
"taxAmt": "0",
"docAmt": "3005797",
"dueAmt": "3005797",
"docType": "INV",
"divCode": null,
"finYear": "2022"
}
]
}
the expected output is
{
"name": "XYZ",
"fields": [
{
"Code": "8000385",
"Number": "9010005790",
"docDate": "19-05-2022",
"dueDate": "30-09-2022",
"totValue": "209121.66",
"taxAmt": "0",
"docAmt": "3005797",
"dueAmt": "3005797",
"docType": "INV",
"divCode": null,
"finYear": "2022",
"Key" : "8000385~9010005790~DOCX" // new field as concatenation of Code and Number
}
]
}
CodePudding user response:
You can use modify transformation along with a concat function such as
[
{
"operation": "modify-default-beta",
"spec": {
"fields": {
"*": {
"Key": "=concat(@(1,Code),'~',@(1,Number),'~DOCX')"
}
}
}
}
]