BDE 4.39.x Production Release
Loading...
Searching...
No Matches
baljsn_convertfromjsonoptions

Detailed Description

Provide an attribute class for JsonConverter "from" options.

Outline

Purpose

Provide an attribute class for JsonConverter "from" options.

Classes

Description

This component provides a single, simply constrained (value-semantic) attribute class, baljsn::ConvertFromJsonOptions, that is used to specify options for converting bdljsn::Json objects to bdlat-compliant objects.

Attributes

Name Type Default Simple Constraints
---------------------- ------- ---------- ----------------------
maxDepth int 512 >= 0
skipUnknownElements bool true none

The default values of maxDepth and skipUnknownElements are the same as the default values of the identically named baljsn::DecoderOptions options.

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 JSON conversion of bdlat objects. This example shows how to create and populate an options object.

First, we default-construct a baljsn::ConvertFromJsonOptions object:

assert(512 == options.maxDepth());
assert(true == options.skipUnknownElements());
Definition baljsn_convertfromjsonoptions.h:118
int maxDepth() const
Return the value of the maxDepth attribute of this object.
Definition baljsn_convertfromjsonoptions.h:278
bool skipUnknownElements() const
Return the value of the skipUnknownElements attribute of this object.
Definition baljsn_convertfromjsonoptions.h:284

Next, we populate that object with custom values:

options.setMaxDepth(10);
assert(10 == options.maxDepth());
options.setSkipUnknownElements(false);
assert(false == options.skipUnknownElements());
void setSkipUnknownElements(bool value)
Definition baljsn_convertfromjsonoptions.h:271
void setMaxDepth(int value)
Definition baljsn_convertfromjsonoptions.h:263