Apache NiFi need to add square brackets around a specific JSON object
I'm new to NiFi, and I've been struggling with wrapping square brackets around a specific JSON object. Below is my JSON input, my desired JSON output and my attempted JoltTransformJSON shift operation spec. I'm really close, but I'm getting a duplicate of the "financialSystemFields" object.
Please advise, and many thanks in advance.
JSON Input:
[{
"type" : "APPROPRIATION",
"subType" : "ADMINISTRATIVE",
"duration" : "1",
"retiredDate" : null,
"expiredDate" : "2023-09-30 00:00:00.0",
"closedDate" : "2028-09-30 00:00:00.0",
"association" : null,
"financialSystemFields" : {
"FundId" : "01234NFWJ",
"fundedProgram" : null,
"projectDescription" : "NO FUN WITH JOLT"
}
}]
Current JSON Output:
[{
"type": "APPROPRIATION",
"subType": "ADMINISTRATIVE",
"duration": "1",
"retiredDate": null,
"expiredDate": "2023-09-30 00:00:00.0",
"closedDate": "2028-09-30 00:00:00.0",
"association": null,
"financialSystemFields": [{
"FundId": "01234NFWJ",
"fundedProgram": null,
"projectDescription": "NO FUN WITH JOLT"
}, {
"FundId": "01234NFWJ",
"fundedProgram": null,
"projectDescription": "NO FUN WITH JOLT"
}]
}]
Desired JSON Output:
[{
"type": "APPROPRIATION",
"subType": "ADMINISTRATIVE",
"duration": "1",
"retiredDate": null,
"expiredDate": "2023-09-30 00:00:00.0",
"closedDate": "2028-09-30 00:00:00.0",
"association": null,
"financialSystemFields": [{
"FundId": "01234NFWJ",
"fundedProgram": null,
"projectDescription": "NO FUN WITH JOLT"
}]
}]
Jolt Operation:
[{
"operation": "shift",
"spec": {
"*": {
"@": "[&1]",
"@(0,financialSystemFields)": "[&].financialSystemFields"
}
}
}]

