intervalSerializationMode

Controls the JSON output format for INTERVAL values during serialization.

Syntax

The value parameter is an INTEGER:

  • 0: Genero default format (default)
  • 1: ISO 8601 duration format

A value outside the allowed range raises error -15824.

intervalSerializationMode is an optional option.

Usage

Use this option to control how INTERVAL values are written to JSON. By default (value 0), the serializer writes INTERVAL values in the Genero native format. Set to 1 to write in ISO 8601 duration format:
  • For year-month interval types, the output format is [-]PnnnnnnnnnYnnM (for example, P36Y06M).
  • For day-second interval types, the output format is [-]PnnnnnnnnnDTnnHnnMnn[.nnnnn]S (for example, P2DT10H30M00S).
The leading field width reflects the declared interval precision (up to 9 digits); trailing fields are zero-padded to their minimum width.

Month, hour, minute, and second parts get a leading zero when only one digit is significant (for example, P36Y06M, not P36Y6M).

For a description of the Genero native and ISO 8601 duration formats, see BDL to JSON type conversion rules.

Note: This option does not apply to util.JSON. For equivalent behavior, use util.JSON.setIntervalSerializationMode.

Affects

Serialization (BDL to JSON)

Example

To write INTERVAL values in ISO 8601 duration format:

CALL json.Serializer.setOption("intervalSerializationMode", 1)

For a complete example, see Serializing DATETIME and INTERVAL values in standard formats.