Skip to main content
Sid17
Silver ⭐️⭐️
November 25, 2025
Question

JOLT to flatten nested JSON

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

1 reply

vafs
Gold ⭐️⭐️⭐️
Gold ⭐️⭐️⭐️
February 17, 2026

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#M250380 

Can you take a look on that and see if it helps? 

Translate
Regards, Andrés Fallas -- Was your question answered? Please take some time to click on "Accept as Solution" below this post. If you find a reply useful, say thanks by clicking on the thumbs-up button.