The util package / JSON classes |
The JSON utility classes implement methods that can convert a Genero BDL RECORD or DYNAMIC ARRAY to a JSON data string. This topic describes how Genero BDL data is converted to JSON data.
When serializing a program variable with the util.JSON.stringify method, empty arrays and empty records (that is where all members are NULL) are written to the resulting string. To avoid empty elements in the JSON string, use the util.JSON.stringifyOmitNulls method instead.
Program array members in the record are converted to JSON arrays delimited by square brackets ([]).
Target Genero BDL type | Description |
---|---|
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 a 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. |
DATE | The date value will be formatted as "YYYY-MM-DD" (with double quotes) |
DATETIME | 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. 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 to convert date-time values to Coordinated Universal Time (UTC), by using the util.Datetime methods. |
INTERVAL | The interval value will be formatted as "YYYY-MM" or "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. |