Splitting a string and mapping it to a JSON Array in Snaplogic

1.8k views Asked by At

Afternoon. I am pulling fields out of salesforce using snaplogic and then calling a rest api with the results. One of the fields that I am mapping to the POST JSON Body needs to be an array. One of the fields that I am pulling out of salesforce is string that is semi-colon delimited. Looking at the snaplogic documentation there is a split(';') function that I can call. In the mapping snap I get this error whenever I try and add an expression to the end of the Salesforce field:

cannot lookup a property on a null value

Is there an example somewhere of splitting a string in a mapper snap and applying it to a rest html body? The documentation on the snaplogic site will verbose is nevertheless unhelpful.

1

There are 1 answers

0
Bilesh Ganguly On BEST ANSWER

You can use the split() method to output an array from the mapper snap.

Following is a sample pipeline:

sample pipeline

Input JSON in the JSON generator:

[
    {
        "msg" : "Test 1;Test 2;Test 3"
    }
]

All settings are left to default.

Mapper Snap:

mapper snap

Expression: $msg.split(';')

Output: [{"msg_array":["Test 1","Test 2","Test 3"]}]