Provide options for decoding JSON into a Datum
object.
More...
Detailed Description
- Outline
-
-
- Purpose:
- Provide options for decoding JSON into a
Datum
object.
-
- Classes:
-
- See also:
- Component baljsn_datumutil
-
- Description:
- This component provides a single, simply constrained (value-semantic) attribute class,
baljsn::DatumDecoderOptions
, that is used to specify options for decoding Datum
objects in the JSON format (see baljsn::DatumUtil
).
-
- Attributes:
Name Type Default Simple Constraints
------------------ ----------- ------- ------------------
maxNestedDepth int 64 > 0
-
maxNestedDepth
: the maximum depth to which JSON objects and arrays are allowed to be nested before the JSON decoder reports an error. For example, if maxNestedDepth
is 8, and a JSON text has 9 consecutive open brackets ([
) the decoding will return an error. This option can be used to prevent poorly formed, or malicious JSON text from causing a stack overflow.
-
- Usage:
- This section illustrates intended use of this component.
-
- Example 1: Creating and Populating an Options Object:
- This component is designed to be used at a higher level to set the options for decoding
Datum
objects in the JSON format. This example shows how to create and populate an options object.
- First, we default-construct a
baljsn::DatumDecoderOptions
object: Finally, we populate that object to limit the maximum nested depth using a pre-defined limit: