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

Expression solution for transformation

Thom
New Contributor II

I have to transform documents that look like the following:
[{
โ€œIdโ€: 999,
โ€œfield1โ€: โ€œvalue1โ€,
โ€œfield2โ€: โ€œvalue2โ€,
โ€œfield3โ€: โ€œvalue3โ€
}
]
Into output like this.
[{
โ€œIdโ€: 999,
โ€œentityโ€: {
โ€œpathโ€: โ€œfield1โ€,
โ€œopโ€: โ€œreplaceโ€,
โ€œvalueโ€: โ€œvalue1โ€
}
},
{
โ€œIdโ€: 999,
โ€œentityโ€: {
โ€œpathโ€: โ€œfield2โ€,
โ€œopโ€: โ€œreplaceโ€,
โ€œvalueโ€: โ€œvalue2โ€
}
},
{
โ€œIdโ€: 999,
โ€œentityโ€: {
โ€œpathโ€: โ€œfield3โ€,
โ€œopโ€: โ€œreplaceโ€,
โ€œvalueโ€: โ€œvalue3โ€
}
}
]
There can be multiple documents being processed and the number of โ€œfieldsโ€ is more (30+) than the example shows. I have created a Mapper snap to do this work for a few fields but would like not to have to do it for 30+. I feel there is an expression/javascript solution to this but I am not well versed at this time.
Any ideas would be appreciated.
Regards,

1 ACCEPTED SOLUTION

Abhishek_Soni37
Contributor

Hi @Thom ,

Iโ€™ve attached a pipeline, hope this helps.
image
Test_Expression_2023_05_31.slp (3.5 KB)

Cheers ๐Ÿ˜‰

View solution in original post

4 REPLIES 4

Abhishek_Soni37
Contributor

Hi @Thom ,

Iโ€™ve attached a pipeline, hope this helps.
image
Test_Expression_2023_05_31.slp (3.5 KB)

Cheers ๐Ÿ˜‰

Thanks so much. This worked as needed.

I'm unable to download the .slp file

dmiller
Admin Admin
Admin

The new community platform didn't quite know how to deal with the .slp file extension. Pipelines need to be zipped before uploaded to this community platform.
Let me find it in the backup.


Diane Miller
Community Manager