cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Getting issue in creating JSON

mohit3
New Contributor

Need to convert the below source JSON to target JSON
Source :
โ€œHeaderโ€:
{
โ€œCustomfieldโ€:
{
โ€œABPERโ€:โ€œ202303โ€,
โ€œABKRSโ€:โ€œSLโ€
}
}

Target :
โ€œHeaderโ€:
{
โ€œCustomfieldโ€:
{
โ€œfieldnameโ€ :โ€œABPERโ€,
โ€œfieldvalueโ€ : โ€œ202303โ€
},
{
โ€œfieldnameโ€ :โ€œABKRSโ€,
โ€œfieldvalueโ€ : โ€œSLโ€
}
}
@dmiller @rsramkoski can you please in converting the json to the above given format.

1 REPLY 1

AleksandarAngel
Contributor III

Hello @mohit3,

You can try with the following expression in a Mapper Snap:

sl.range(0,$Header.Customfield.entries().length).map( (x,ind) => {"fieldname":$Header.Customfield.entries()[ind][0], "fieldvalue":$Header.Customfield.entries()[ind][1]})

image

Here is a sample pipeline:
โ€“sl-comm-json-transform_2023_07_05.slp (3.7 KB)

Let me know if this helps you.

Regards,
Aleksandar.