BDL to JSON type conversion rules

Specific type conversion rules apply when converting a BDL variable to JSON.

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

Will be serialized with the JSON values true or false.

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

Any numeric type will be serialized to this form: an optional minus sign (-), a sequence of digits (0-9), containing an optional decimal separator (.), followed by an optional exponent. The exponent has the form (e) followed by an optional minus sign and an sequence of digits. The representation of numeric values does not depend from the current locale. The decimal separator is always a dot (.). MONEY values will be represented like DECIMAL values: the currency symbol will be omitted. Some JSON classes have limitation based on binary64, see JSON number limitations.

DATE

The date value will be formatted as "YYYY-MM-DD" (with double quotes)

DATETIME qual1 TO qual2

The date-time value will be formatted as "YYYY-MM-DD hh:mm:ss.fffff" (with double quotes), based on the date-time type definition. For example, a DATETIME HOUR TO MINUTE will produce "hh:mm" formatted values. In this form, the date/time value represents a local time on the system where the JSON data is produced.

Date/time values can be converted from/to UTC by using the util.Datetime methods.

INTERVAL YEAR TO MONTH, INTERVAL YEAR TO YEAR

The interval value will be formatted as "YYYY-MM" (with double quotes), depending on the interval type definition.

INTERVAL DAY TO FRACTION(n), INTERVAL DAY TO SECOND, INTERVAL DAY TO MINUTE, INTERVAL DAY TO HOUR The interval value will be formatted as "DD hh:mm:ss.fffff" (with double quotes), depending on the interval type definition.
BYTE

Will be serialized to a Base64 encoded double quoted string. The Base64 encoding is described in [RFC4648].

TEXT, CHAR, VARCHAR, STRING

Character string data will be serialized as a double quoted string with backslash escaping.

List of characters requiring escaping:
  \\  backslash       U+005C
  \"  quotation mark  U+0022
  \b  backspace       U+0008
  \f  form feed       U+000C
  \n  line feed       U+000A
  \r  carriage return U+000D
  \t  tab             U+0009
Other

Any other type will be serialized as a double quoted (") string.