User Guide : Map Connectors : Source and Target Map Connectors : JSON
 
Share this page                  
JSON
JavaScript Object Notation (JSON) is a text-based open standard designed for human readable data interchange. It is derived from the JavaScript scripting language for representing simple data structures and associative arrays, called objects. Despite its relationship with JavaScript, it is language-independent with parsers available for many languages. The official Internet media type for JSON is application/json. The JSON filename extension is .json. The JSON format is often used for serializing and transmitting structured data over a network connection. It is used primarily to transmit data between a server and web application, serving as an alternative to XML. "JSON." Wikipedia, The Free Encyclopedia, http://en.wikipedia.org/wiki/JSON (accessed May 11, 2017).
Note:  Normally, schemas for target multimode connectors are not provided. However, for JSON connector, if the target file exists, then the UI connects using a source JSON Connection and then the schema is copied to the target.
JSON is built on two structures:
A collection of name/value pairs. In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array.
An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence.
Connectivity Requirements
The JSON connector allows you to store and connect to your source and target data using the following methods:
Source and target files can be stored on the local file system where DataConnect is installed, and then accessed through shared storage locations.
Source and target files can be stored in an external system and accessed through HTTP(S) requests.
Property Options
 
Property
S/T
Description
Batch Size
S
Number of source records the connector caches before processing them in a map. Default is 100.
Read Nulls
S
If set to True, the connector reads null values in the source file.
If set to False, null values in the source file are skipped. The null field is added to the schema, but it is skipped when the map is run.
Default is True.
Read Empty Tokens
S
If set to True, the connector reads empty array ([]) and empty object ({}) values in the source file.
If set to False, empty array ([]) and empty object ({}) values in the source file are skipped. The schema is updated with a reference to a new record and the JSON INPUT field holds the {} and [] characters, respectively. The characters in the JSON INPUT field are not mapped to the target.
Default is True.
Data Types
The supported data types correspond to the fields in the target data table. If you are appending data to an existing table, then the data type of each field uses the data type in the selected table by default.
JSON connector supports the following data types:
Base64Binary
Boolean
Byte
Char
Date
DateTime
Decimal
Double
Float
HexBinary
Integer
Long
Short
String
Time
Additional Information
Batch Response
A batch response file contains a group of entries for each connector used in a batch operation. Each action in the operation generates a batch response entry. These entries often provide detailed information, such as errors, that can be used for troubleshooting.
Example
<BatchResponse:batchResult xmlns:BatchResponse="http://www.actian.com/BatchResponse">
<BatchResponse:results>
</BatchResponse:results>
<BatchResponse:componentInfo>
<BatchResponse:returnCode>0</BatchResponse:returnCode>
<BatchResponse:componentName>JSON-DMS</BatchResponse:componentName>
</BatchResponse:componentInfo>
</BatchResponse:batchResult>
Schema Considerations
Normally, schemas for target multimode connectors are not provided. However, for JSON connector:
If the target file exists, the UI connects using a source JSON connection and then the schema is copied to the target. The schema is built from the data, which may be a subset of the actual schema.
If the target file does not exist, then the following is performed:
1. Automatically create a target record with one field and then you can drag-and-drop the source fields to the target.
2. Use an external schema (created using Schema Editor or saving the schema from a map source or target). If you use this method, it will replace the automatically created target record.
Custom JSON
If the JSON_INPUT field is mapped on the target side, the field is a string field and the connector will treat the mapped string as Custom JSON. There are some considerations you need to take into account when using the JSON_INPUT field:
The JSON connector will not validate the data in the JSON_INPUT field. You are responsible for providing syntactically correct JSON.
Warning!  The JSON connector may output invalid JSON if you do not validate the JSON when mapping the Custom JSON field.
If the JSON_INPUT field is mapped on a record, all child records of this record will be skipped, even if they are mapped. The remaining fields on the record will be skipped as well (even if they are mapped).
Since the JSON_INPUT field is a string, you must escape any string contained in the custom JSON data field. The following sample shows proper string syntax when mapping to the JSON_INPUT field:
User input to JSON_INPUT field:"{""Field"":""Value"", ""Field2"":12}""Connector output for JSON_INPUT:{"Field":"Value", "Field2":12}
In this example, Field, Value, and Field2 are strings. The value of 12 is an integer.