Member since
12-10-2024
7
Posts
6
Kudos Received
0
Solutions
11-24-2025
10:28 PM
Hi Team, I'm trying to flatten a nested JSON and it is working fine for few cases which has data but for some cases if it has [] empty then the record is not showing up in the result. Could you please help me in tackling this corner case. My data: {
"data": {
"getVarietyListing": {
"edges": [
{
"node": {
"id": "346595",
"identifier": 503882,
"description": "Estefania (PL)",
"productLifecycleManagementAreas": []
}
},
{
"node": {
"id": "351741",
"identifier": 504382,
"description": "Amsterdam 2 - ABK",
"productLifecycleManagementAreas": [
{
"code": {
"code": "X00",
"description": "Prepare to retire"
},
"startDate": "2025-09-01",
"futureStartDate": null,
"futureCode": null,
"area": {
"country": "EA"
}
},
{
"code": {
"code": "X00",
"description": "Prepare to retire"
},
"startDate": "2025-09-01",
"futureStartDate": null,
"futureCode": null,
"area": {
"country": "FR"
}
},
{
"code": {
"code": "X00",
"description": "Prepare to retire"
},
"startDate": "2024-04-11",
"futureStartDate": null,
"futureCode": null,
"area": {
"country": "IL"
}
},
{
"code": {
"code": "X00",
"description": "Prepare to retire"
},
"startDate": "2025-09-01",
"futureStartDate": null,
"futureCode": null,
"area": {
"country": "NL"
}
},
{
"code": {
"code": "X00",
"description": "Prepare to retire"
},
"startDate": "2025-09-01",
"futureStartDate": null,
"futureCode": null,
"area": {
"country": "TR"
}
},
{
"code": {
"code": "X00",
"description": "Prepare to retire"
},
"startDate": "2025-09-01",
"futureStartDate": null,
"futureCode": null,
"area": {
"country": "GB"
}
}
]
}
}
]
}
}
} This is the data and I'm using the following JOLT: [
{
"operation": "shift",
"spec": {
"data": {
"getVarietyListing": {
"edges": {
"*": {
"node": {
"productLifecycleManagementAreas": {
"*": {
"@(2,identifier)": "[&4].[&1].Variety",
"@(2,description)": "[&4].[&1].VarietyDescription",
"startDate": "[&4].[&1].StartDate",
"futureCode": {
"code": "[&5].[&2].FuturePlcCode"
},
"futureStartDate": "[&4].[&1].FutureStartDate",
"code": {
"code": "[&5].[&2].PlcCode",
"description": "[&5].[&2].PlcCodeDescription"
},
"area": {
"country": "[&5].[&2].Country"
}
}
}
}
}
}
}
}
}
},
{
"operation": "shift",
"spec": {
"*": {
"*": {
"@": "[]"
}
}
}
},
{
"operation": "default",
"spec": {
"*": {
"Country": null
}
}
}
] For the identifier 503882, I'm not getting any result becuase of "productLifecycleManagementAreas": [] it is empty. I need to get identifier and also description and rest all attributes can be hardcoded to null. Your help matters a lot. Thank you
... View more
Labels:
- Labels:
-
Apache NiFi
12-20-2024
02:39 AM
1 Kudo
Thank you @SAMSAL (JOLT expert), The spec you posted worked properly and I'm able to see the flat JSON as expected.
... View more
12-11-2024
08:59 PM
2 Kudos
Hi Samsal, Firstly I want to thank you for taking your time in solving my query. The solution you provided worked like a magic. Secondly, yes I am new to this platform and also for JOLT, moving forward I will follow your tips and suggestions and will go through the courses which you've shared. Once again thank you for your valuable assistance. It made a significant difference. I am grateful.
... View more