Quick Links:

bal | bbl | bdl | bsl

Namespaces

Component baljsn_decoderoptions
[Package baljsn]

Provide an attribute class for specifying JSON decoding options. More...

Namespaces

namespace  baljsn

Detailed Description

Outline
Purpose:
Provide an attribute class for specifying JSON decoding options.
Classes:
baljsn::DecoderOptions options for decoding objects in the JSON format
See also:
Component baljsn_decoder, Component baljsn_encoderoptions
Description:
This component provides a single, simply constrained (value-semantic) attribute class, baljsn::DecoderOptions, that is used to specify options for decoding objects in the JSON format.
Attributes:
  Name                  Type           Default         Simple Constraints
  ------------------    -----------    -------         ------------------
  maxDepth              int            32              >= 0
  skipUnknownElements   bool           true            none
  validateInputIsUtf8   bool           false           none
  • maxDepth: maximum depth of the decoded data
  • skipUnknownElements: flag specifying if unknown elements are skipped
  • validateInputIsUtf8: flag specifying whether UTF-8 correctness checking is enabled.
Implementation Note:
This file was generated from a script and was subsequently modified to add documentation and to make other changes. The steps to generate and update this file can be found in the doc/generating_codec_options.txt file.
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 objects in the JSON format. This example shows how to create and populate an options object.
First, we default-construct a baljsn::DecoderOptions object:
  const int  MAX_DEPTH             = 10;
  const bool SKIP_UNKNOWN_ELEMENTS = false;

  baljsn::DecoderOptions options;
  assert(32   == options.maxDepth());
  assert(true == options.skipUnknownElements());
Next, we populate that object to decode using a different maxDepth value and skipUnknownElements value:
  options.setMaxDepth(MAX_DEPTH);
  assert(MAX_DEPTH == options.maxDepth());

  options.setSkipUnknownElements(SKIP_UNKNOWN_ELEMENTS);
  assert(SKIP_UNKNOWN_ELEMENTS == options.skipUnknownElements());