BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bdljsn_readoptions

Detailed Description

Outline

Purpose

Provide options for reading a JSON document.

Classes

See also
bdljsn_jsonutil, bdljsn_json

Description

This component provides a single, simply constrained (value-semantic) attribute class, bdljsn::ReadOptions, that is used to specify options for reading a JSON document (see bdljsn_jsonutil ).

Attributes

Name Type Default Simple Constraints
------------------ ----------- ------- ------------------
maxNestedDepth int 64 > 0
allowTrailingText bool false

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 bdljsn::ReadOptions object:

const int MAX_NESTED_DEPTH = 16;
assert(64 == options.maxNestedDepth());
assert(false == options.allowTrailingText());
Definition bdljsn_readoptions.h:128
int maxNestedDepth() const
Return the maxNestedDepth attribute of this object.
Definition bdljsn_readoptions.h:282
bool allowTrailingText() const
Return the allowTrailingText attribute of this object.
Definition bdljsn_readoptions.h:276

Finally, we populate that object to limit the maximum nested depth using a pre-defined limit:

options.setMaxNestedDepth(MAX_NESTED_DEPTH);
assert(MAX_NESTED_DEPTH == options.maxNestedDepth());
ReadOptions & setMaxNestedDepth(int value)
Definition bdljsn_readoptions.h:266