06-13-2023 03:57 AM
Hello Snaplogic experts,
is it possible from input
[
{
"Manufacturer":
"BMW"
"type":
"M3"
"Fuel":
"petrol"
}
{
"Manufacturer":
"BMW"
"type":
"M5"
"Fuel":
"petrol"
}
{
"Manufacturer":
"Mercedel"
"type":
"GLS"
"Fuel":
"diesel"
}
]
create output like this:
[
{
"Manufacturer": BMW
"Infos":
[
{
"type":"M3"
"Fuel":"petrol"
}
{
"type":"M5"
"Fuel":"petrol"
}
]
}
{
"Manufacturer": Mercedes
"Infos":
[
{
"type":"GLS"
"Fuel":"diesel"
}
]
}
]
ive tried with group by fields and withou success … iam curious if it is possible to add “Infos” into output, if it wasnt mentioned in input
thank you
Solved! Go to Solution.
06-13-2023 04:12 AM
Hello,
You can achieve this by using a Mapper Snap with the following settings:
Try it, and let me know if this helps.
BR,
Aleksandar.
06-14-2023 02:24 AM
Hi, it looks like this:
[
{
"Manufacturer": BMW
"Infos":
[
{
"type":"M3"
"Fuel":"petrol"
}
]
"Manufacturer": BMW
"Infos":
[
{
"type":"M5"
"Fuel":"petrol"
}
]
}
{
"Manufacturer": Mercedes
"Infos":
[
{
"type":"GLS"
"Fuel":"diesel"
}
]
}
]
i would like to group it/sort it under one Manufacturer
06-14-2023 02:28 AM
You can try as I have in the pipeline attached below.
First I’m grouping by the Manufacturer field, and then I’m concatenating the Infos arrays in one array.
–sl-comm-hierarchial-json_2023_06_14.slp (8.1 KB)
Regards,
Aleksandar.
06-14-2023 02:33 AM
Thank you very much Aleksandar …thats what i was looking for