Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]
Created 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
Created 02-17-2026 09:47 AM
Hello @Sid17,
This looks very similar to what we see here:
https://community.cloudera.com/t5/Support-Questions/Jolt-spec-to-flatten-the-nested-JSON/m-p/399054#...
Can you take a look on that and see if it helps?