Forum Discussion

SL12345's avatar
SL12345
New Contributor III
3 years ago
Solved

Create hierarchical Json from mapper output

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

  • 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.