03-06-2017 02:54 AM
Using Mapper, we can change the Object in to array.
In the below pipeline , data is generated using csv generator in plain text.
Pipeline
CSV generator configurations
Changing the name from object to list.
$Name instanceof Array?$Name :[$Name]
Here name is the attribute which is reffered from csv generator and is converted to list from object.
Output of Mapper
[ { "Name": [ "Harish" ], "age": "26" } ]
Here added an JSON splitter to read the list from the output of mapper.
Below is the output of JSON splitter.
[ { "splitValue": "Harish" } ]
Attaching the sample pipeline.Array to Object_2017_03_06.slp (4.0 KB)
05-13-2019 03:06 AM
You can also use the sl.ensureArray($Name) expression. Using this expression you will make sure that the $Name object will be array.