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