JSON to BDL type conversion rules

Specific type conversion rules apply when parsing a JSON string to fill a BDL variable.

Table 1. JSON to Genero BDL type conversion rules
JSON source string Target Genero BDL type
The JSON string must be a JSON object in the form:
{ "record-element-name" : json-value [,...] }
RECORD ... END RECORD
The JSON string must be a JSON array in the form:
[ json-value [,...] ]
DYNAMIC ARRAY OF ...
The JSON string must be a JSON object in the form:
{ "dictionary-key" : json-value [,...] }
DICTIONARY OF ...

The JSON value should be null, true or false. If the JSON value is a number or a string, the language conversion rules from number/string to BOOLEAN apply.

BOOLEAN

A JSON number. The JSON number can be assigned to any language numeric type. The limits of the target type cause potential overflows errors. On error the target variable will be initialized to NULL, the parser continues without an error.

TINYINT, SMALLINT, INTEGER, BIGINT, SMALLFLOAT, FLOAT, DECIMAL, MONEY

The JSON value must be a string formatted as "YYYY-MM-DD".

DATE

A JSON string representing a datetime or a JSON number.

If the value is a JSON string, it must be formatted as "YYYY-MM-DD hh:mm:ss.fffff", or represent as an ISO 8601 formatted date-time, in UTC (with Z indicator) or with a timezone offset (+/-hh[:mm]). For example: "2013-02-21T15:18:44.456Z", "2013-02-21T20:18:44.456+02:00".

If the value is a JSON number, it is interpreted as UNIX™ time (seconds since the Epoch 00:00:00 UTC, January 1, 1970).

Note that the YYYY-MM-DD hh:mm:ss.ffff format is used to represent the local time. When exchanging date-time values in communications across different time zones, consider converting date-time values to Coordinated Universal Time (UTC), by using the util.Datetime methods.

DATETIME

The JSON value must be a string formatted as "YYYY-MM" or "DD hh:mm:ss.fffff", depending on the interval class of the target variable.

INTERVAL

The JSON string value must be encoded in Base64.

The Base64 encoding is described in [RFC4648].

BYTE

A JSON string or number.

If the JSON value is a number, the resulting BDL string value uses the locale specific decimal point.

If the JSON value is a string: Any character in the Basic Multilingual Plane (U+0000 through U+FFFF) may be escaped: \u followed by exactly 4 hexadecimal digits ([0-9a-fA-F]). The hexadecimal digits encode the code point. Characters outside the Basic Multilingual Plane may be escaped by there UTF-16 surrogate pairs. For example, the representation of the G clef character (U+1D11E) is "\uD834\uDD1E".

TEXT, CHAR, VARCHAR, STRING