Overview
Data flow transformation to extract structured data from a text column, storing arrays with objects in JSON, XML or other text format. An optional transformation function is used to convert raw array to JSON array.
Setup
The script has the following parameters:
- DataColumn - specifies columns containing the input data. When multiple columns are selected, the content parameter passed to the Transform function will be a JavaScript object where each selected input column will be configured as an object member.
- Sample - sample data to initialize metadata. It would be used for the creation of output columns. If the sample is changed the output columns will be deleted and recreated.
- Transform - specifies transformation function to create JSON array before output. underscore.js functions are also available for use by default. The parameter of this function is the whole input array. To quickly test the transformation function, one of the online JavaScript Editors - JS Bin can be used. Here is the example transformation where "Price" is multiplied by the exchange rate. When a single input column is selected the contents are passed without modification. The function should parse the input. When multiple columns are selected the script tries to parse the data, if not possible the data is passed unchanged. All columns data is passed as a JavaScript object where property names are the column names and values containing the column data.
- IsSequence - specifies if the result is a single record or multiple. When a single record is selected the output is synchronous, otherwise asynchronous.
- IncludeSequenceTerminator - specifies if an empty row will be added to the output after the processing of an input row. This is useful when input rows contain arrays of multiple objects, e.g. in the context of SSIS+ support for composite records.
Handling different types of input format
The default transformation function expects JSON array as a string. If your input is different, you can customize the transformation function according to your needs. Please check the QuickStart(s) below for further information.
Quick Start
In this quick-start we will setup a JSON Transformation.
Providing sample data
The format of the sample data is array of JSON objects. All objects are processed and from their properties the output columns are created. The columns are created immediately after changing value of the parameter. If "Sample" is changed the current output columns are deleted and the new are created.
In this quick-start we will setup a XML Transformation.
Providing sample data
The format of the sample data is XML text. The XML is converted to JSON and only the array is returned. This is done by the transformation function. The sample data is in XML format because the input data is also in XML format. After the JSON array is returned from transformation all objects are processed and from their properties the output columns are created. The columns are created immediately after changing value of the parameter. If "Sample" is changed the current output columns are deleted and the new are created.
Sample data used:
XML elements with name person
will be converted to JavaScript Array.
Configuration
To use this script, you would need to load it in COZYROC JavaScript Component. If you are using COZYROC SSIS+ 2.0 or later, after selecting the corresponding script type and opening the component editor, you can select the script from a dropdown list with the pre-built scripts. For COZYROC SSIS+ 1.9, you can download the JavaScript file and browse to it via the "Import JavaScript code" button.
JSON_Transformation.jsKnowledge Base
COZYROC SSIS+ Components Suite is free for testing in your development environment.
A licensed version can be deployed on-premises, on Azure-SSIS IR and on COZYROC Cloud.