Converting Nested JSON to Flat JSON using JOLT
Hi team,
I'm struggling while converting nested JSON to Flat JSON using JOLT.
The Nested JSON is in the below format:
{
"data": {
"getCarListing": {
"edges": [
{
"node": {
"id": "1001",
"identifier": 500001,
"carClusterIds": [
{
"element": {
"name": "SEDAN1000",
"businessRelations": [
{
"countries": [
{
"countryCode": "US"
}
],
"code": "US01"
},
{
"countries": [
{
"countryCode": "CZ"
},
{
"countryCode": "SK"
}
],
"code": "CZ01"
},
{
"countries": [
{
"countryCode": "CA"
}
],
"code": "CA01"
}
]
},
"metadata": [
{
"name": "clusterId",
"value": "200011"
}
]
},
{
"element": {
"name": "SUV2020",
"businessRelations": [
{
"countries": [
{
"countryCode": "MX"
}
],
"code": "MX01"
}
]
},
"metadata": [
{
"name": "clusterId",
"value": "200012"
}
]
}
],
"parentItems": [
{
"identifier": 400050
}
]
}
},
{
"node": {
"id": "1002",
"identifier": 500002,
"carClusterIds": [
{
"element": {
"name": "TRUCK500",
"businessRelations": [
{
"countries": [
{
"countryCode": "FR"
}
],
"code": "FR01"
},
{
"countries": [
{
"countryCode": "DE"
}
],
"code": "DE01"
}
]
},
"metadata": [
{
"name": "clusterId",
"value": "200021"
}
]
},
{
"element": {
"name": "COUPE3000",
"businessRelations": [
{
"countries": [
{
"countryCode": "JP"
}
],
"code": "JP01"
}
]
},
"metadata": [
{
"name": "clusterId",
"value": "200022"
}
]
}
],
"parentItems": [
{
"identifier": 400051
}
]
}
}
]
}
}
}
I want the output in this format:
[
{
"Element" : "SEDAN1000",
"BR" : "US01",
"CountryCode" : "US"
},
{
"Element" : "SEDAN1000",
"BR" : "CZ01",
"CountryCode" : "CZ"
},
{
"Element" : "SEDAN1000",
"BR" : "CZ01",
"CountryCode" : "SK"
},
{
"Element" : "SEDAN1000",
"BR" : "CA01",
"CountryCode" : "CA"
},
{
"Element" : "SUV2020",
"BR" : "MX01",
"CountryCode" : "MX"
}
]
Can anyone please help me with the JOLT spec that can be used to derive the nested JSON to the required Flat JSON.
Thanks in Advance...


