Forum Discussion

Thom's avatar
Thom
New Contributor II
3 years ago
Solved

Expression solution for transformation

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,

4 Replies

    • Thom's avatar
      Thom
      New Contributor II

      Thanks so much. This worked as needed.

    • aakumar's avatar
      aakumar
      New Contributor III

      I'm unable to download the .slp file

  • dmiller's avatar
    dmiller
    Former Employee

    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.