DataSonnet Header

The header is an optional comment section in the mapping document which must start with /** DataSonnet followed by a new line character and end with a line */ and contains a set of configuration properties. The properties are hierarchical, with sections separated by the ` ` (space) character, e.g.:

input payload application/xml;namespace-separator=":";text-value-key=__text
input myVar application/csv;quote="""

The header must be the first comment before any other line of code, in the following format:

/** DataSonnet
version=<VERSION_NUMBER>
<PROPERTY>=<VALUE>
...
*/

Example

/** DataSonnet
version=1.0
*/
//DataSonnet mapping starts here
{
    mappedValue: payload.value
}

The header is optional; if omitted, all default settings will be used. The default version is 1.0. For the data format-specific defaults see the Data Formats section.

Data Format Properties

The data format properties control the data format plugins behavior. The property names must start with one of input|output|*. The input properties format must be input <INPUT_NAME>|* <MIME_TYPE>;<MIME_TYPE_SPECIFIC_PARAMETER>, where:

  • <INPUT_NAME> is a name of input variable or payload;

  • <MIME_TYPE> is a mime type supported by DataSonnet;

  • <MIME_TYPE_SPECIFIC_PARAMETER> is one of the parameters supported by the plugin for this mime type.

Additional <MIME_TYPE_SPECIFIC_PARAMETER>`s can be added with a `; (semicolon). The values that should be escaped with quotes are ; (semicolon), : (colon), " (quote) and , (comma).

If a property is not recognized, an error will be raised.

The wildcard * can be used to set the same parameter value for all inputs and output of the given format, instead of defining it explicitly. For example:

* application/csv;separator=|

is an equivalent of:

input payload application/csv;separator=|
input myVar application/csv;separator=|
output application/csv;separator=|

The wildcard may be used for inputs only, e.g.

input * application/csv;separator=|
output application/csv;separator=","

An explicit setting will override the wildcard setting for a specific input or output. For example, if there are multiple CSV inputs that have separator | except one that has separator ,, the following configuration can be used:

dataformat application/csv;*.separator=|
dataformat application/csv;commaSeparatedVar.separator=","

For the list of the supported data formats and their configurable properties, see the Data Formats section.

Miscellaneous Properties

Header Description Required Default value

version

DataSonnet language version. Currently this property has no effect on the DataSonnet behavior.

no

1.0

preserveOrder

Controls whether order of fields as they appear in the mapping will be preserved in the resulting JSON.

no

true

default

Provides a default JSON value that will be returned when non-existent keys are selected.

no