cancel
Showing results for 
Search instead for 
Did you mean: 

Transform a flat json list into a list of objects

Tord
New Contributor

Being pretty new to SnapLogic I struggle a lot with processing Json data. Currently I am trying to process a SOAP response. After the first processing, I have a flat list of attributes:

[
{ “START_RECORD”: null },
{ “ATTR1”: 123 },
{ “ATTR2”: “xyz” },
{ “END_RECORD”: null },
{ “START_RECORD”: null },
{ “ATTR1”: 456 },
{ “ATTR2”: “abc” },
{ “END_RECORD”: null }
]

In this list START_RECORD and END_RECORD marks the start and end of data records. I need to transform this list into something like below for further processing:

[
{ “RECORD”: [
{ “ATTR1”: 123 },
{ “ATTR2”: “xyz” }
]},
{ “RECORD”: [
{ “ATTR1”: 456 },
{ “ATTR2”: “abc” }
]}
]

Do you have ideas how to to that transformation? Because I did not find another solution yet, I am writing a JavaScript to do the job. It will work but it just does not feel right.

0 REPLIES 0