JSON Writer

The JSON Write transform allows you to generate JSON data. The write transform can be written to either an HTTP Url or to file.

JPath Handling

Transaction Types

Except for the top transaction, which will always be written, only transactions with a non-empty JPATH (see JPath) will be written. Where a transaction type has an empty JPath none of the sibling transactions will be written.

A transaction JPath can be either one or multiple segments.

The last segment of a record’s JPath will generate an array where the child records will be inserted as objects.

The array of child records will be created irrespective of whether the segment has an array indicator.

Array in JPath (Transaction or Field)

If an array is specified in an intermediate node of a JPath (either field or record) an array will be created. The next node of the path will be created as a property within an object.

Fields

A transaction JPath can be either one or multiple segments.

Fields with multiple segments will be merged with other fields with similar node paths.

The last segment of a field will either generate a property or an array depending on whether the segment has array indicator.

Only fields which have a value will generate a property in the resulting JSON document.

Array Fields

If an array is specified as the last segment in a fields JPath the value of the field will be written as an array. Multiple values may be set to the array by separating each value in the field by a pipe character ‘|’.

Text values may be optionally enclosed in double quotes. If a value has an unterminated quote character the field’s entire value will be set as the single value in the array.

Field Types

A field’s value will be converted to its underlying field type. If the field cannot be converted a conversion or parse error may be raised.

Date Types

Dates are converted to the ISO 8601 format: yyyy-mm-ddThh:mm:ss.nnnZ e.g.

21st January 2015 9:52:12AM -> ‘2015-01-21T09:52:12.000Z’

Example

Transform > Setup

Transform Id

The unique Id for the transform.

Data Source

The controller type i.e. the source from where the JSON data will be written. This can be File or Http. See IO Controllers.

Create File No Data

When enabled will write to the selected IO Controller irrespective of whether there is data in the IMan dataset.

Generate File Per Transaction

Generates a document for each instance of the selected transaction type.

Omit Header Object

  • Selected
    • Will not write either the Initial JPath or top transaction’s JPath.
  • If combined with the ‘Generate File Per Transaction’ property
    • Enables a JSON document to be created without the outer JSON Nodes where the resulting documents containing only the transactional elements.

In the previous example, this would result in the “document” and “orders” nodes being dropped from each document. Each object within the array would then be written as a separate document.

Rewrite Response Transaction

Allows you write the response back to the IMan dataset.

See Rewrite (HTTP) Write Response

Transform > Field Mapping

Initial JPath

The node path to write at the beginning of the document.

Current Transaction Id

The transaction type being edited.

Transaction JPath

The node path to write at the beginning of each transaction type.

Field Name

The field name.

Export Field

Includes the field in the resulting document when selected.

Is Relative JPath

When selected, the JPath are appended to the Record XPath value, otherwise the expression is an absolute path.

JPath

If the field is marked as relative the resultant nodes from the JPath will be appended to the Transaction’s JPath.

When the relative is deselected the field is an absolute path. This allows fields to specify JPath expressions to be inserted that are outside of the child-parent node relationship.