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

Detailed Description

Provide options for conversion of bdlat to Json objects.

Outline

Purpose

Provide options for conversion of bdlat to Json objects.

Classes

Description

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

Attributes

Name Type Default Simple Constraints
---------------------- ------- ---------- ----------------------
convertEmptyArrays bool true none
convertNullElements bool true none

The default values of these options are the opposite of the default values of the similarly named baljsn::EncoderOptions 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::ConvertToJsonOptions object:

assert(true == options.convertEmptyArrays());
assert(true == options.convertNullElements());
Definition baljsn_converttojsonoptions.h:115
bool convertEmptyArrays() const
Return the value of the convertEmptyArrays attribute of this object.
Definition baljsn_converttojsonoptions.h:273
bool convertNullElements() const
Return the value of the convertNullElements attribute of this object.
Definition baljsn_converttojsonoptions.h:279

Next, we populate that object with custom values:

options.setConvertEmptyArrays(false);
assert(false == options.convertEmptyArrays());
options.setConvertNullElements(false);
assert(false == options.convertNullElements());
void setConvertEmptyArrays(bool value)
Definition baljsn_converttojsonoptions.h:259
void setConvertNullElements(bool value)
Definition baljsn_converttojsonoptions.h:265