cancel
Showing results for 
Search instead for 
Did you mean: 

Parsing of json object with dynamic attribute keys

Bobby
New Contributor

Hi,
I have a nested json, with the inner most element is an array of struct.
The key to identify this inner element is a dyamic value. see the numeric value in the below json.

the json parser snap works fine with this, but when it comes to splitter, I am not able to give the actual value to split on. has anyone worked had success with a json like this ?

{
“VehicleName”: “Test Automobile”,
“VehicleId”: 0000011111,
“renderedDate”: “2022-03-02”,
“alternativeVehicle”:
{
0000002222”:
[
{
“priority”: “1”,
“VehiclelabelName”: “Car 1”,
“VIN”: 72183,
“type”: “Manual”
},
{
“priority”: “2”,
“VehiclelabelName”: “Van 1”,
“VIN”: 72166,
“type”: “Auto”
}
],
“00002144509”:
[ {
“priority”: “1”,
“VehiclelabelName”: “miniVan 1”,
“VIN”: 72432,
“type”: “Auto”
}
]
}
}

1 REPLY 1

Supratim
Contributor III

@Bobby try below expression in mapper and name vehicleList in target mapper. Then use json splitter. PFB screenshot.

$alternativeVehicle.mapValues((val,key) => val.map(ele=> ele.extend({“vehicleKey”:key}))).values()

image

image

image