Options for performing JSON encoding. EncodingStyle is either COMPACT or PRETTY. If EncodingStyle is COMPACT, no whitespace will be added between elements. If encoding style is PRETTY, then the InitialIndentLevel and SpacesPerLevel parameters are used to specify the formatting of the output. Note that InitialIndentLevel and SpacesPerLevel are ignored when EncodingStyle is COMPACT (this is the default). The EncodeEmptyArrays and EncodeNullElements encode empty array and null elements respectively. By default empty array and null elements are not encoded. The EncodeInfAndNaNAsStrings attribute provides users the option to encode Infinity and NaN floating point values as strings. These values do not have a valid JSON representation and by default such value will result in an encoding error. The DatetimeFractionalSecondPrecision specifies the precision of milliseconds printed with date time values. By default a precision of 3 decimal places is used. The MaxFloatPrecision and MaxDoublePrecision attributes allow specifying the maximum precision for float and double values. When not specified, or 0 is specified, the precision is determined automatically to use enough digits to ensure restoring the original binary floating point value by a reader. We recommend against setting these options: they were provided prior to the current default behavior (of choosing the shortest presentation that can be restored to the original value) being available.

Synopsis

Declared in <baljsn_encoderoptions.h>

class EncoderOptions;

Enums

Name

Description

Unnamed enum

Attribute identifier constants.

Unnamed enum

Attribute count constants.

Unnamed enum

Attribute index constants.

EncodingStyle

This enum provides enumerators to specify the encoding styles. This enum is replicated in this class for backwards‐compatibility with baejsn. Users should use baljsn::EncodingStyle directly.

Member Functions

Name

Description

EncoderOptions [constructor]

Constructors

~EncoderOptions [destructor]

Destroy this object.

operator=

Assign to this object the value of the specified rhs object.

accessAttribute

accessAttribute overloads

accessAttributes

Invoke the specified accessor sequentially on each (non‐modifiable) attribute of this object, supplying accessor with the corresponding attribute information structure until such invocation returns a non‐zero value. Return the value from the last invocation of accessor (i.e., the invocation that terminated the sequence).

datetimeFractionalSecondPrecision

Return a reference to the non‐modifiable "DatetimeFractionalSecondPrecision" attribute of this object.

encodeAnonSequenceInChoice

Return the value of the "EncodeAnonSequenceInChoice" attribute of this object.

encodeEmptyArrays

Return a reference to the non‐modifiable "EncodeEmptyArrays" attribute of this object. Note that empty arrays occurring as selections of choices are always encoded regardless of the setting of this option.

encodeInfAndNaNAsStrings

Return a reference to the non‐modifiable "EncodeInfAndNaNAsStrings" attribute of this object.

encodeNullElements

Return a reference to the non‐modifiable "EncodeNullElements" attribute of this object.

encodeQuotedDecimal64

Return the value of the "EncodeQuotedDecimal64" attribute of this object.

encodingStyle

Return a reference to the non‐modifiable "EncodingStyle" attribute of this object.

escapeForwardSlash

Return the value of the "EscapeForwardSlash" attribute of this object.

initialIndentLevel

Return a reference to the non‐modifiable "InitialIndentLevel" attribute of this object.

manipulateAttribute

manipulateAttribute overloads

manipulateAttributes

Invoke the specified manipulator sequentially on the address of each (modifiable) attribute of this object, supplying manipulator with the corresponding attribute information structure until such invocation returns a non‐zero value. Return the value from the last invocation of manipulator (i.e., the invocation that terminated the sequence).

maxDoublePrecision

Return a reference to the non‐modifiable "MaxDoublePrecision" attribute of this object.

maxFloatPrecision

Return a reference to the non‐modifiable "MaxFloatPrecision" attribute of this object.

print

Format this object to the specified output stream at the optionally specified indentation level and return a reference to the modifiable stream. If level is specified, optionally specify spacesPerLevel, the number of spaces per indentation level for this and all of its nested objects. Each line is indented by the absolute value of level * spacesPerLevel. If level is negative, suppress indentation of the first line. If spacesPerLevel is negative, suppress line breaks and format the entire output on one line. If stream is initially invalid, this operation has no effect. Note that a trailing newline is provided in multiline mode only.

reset

Reset this object to the default value (i.e., its value upon default construction).

setDatetimeFractionalSecondPrecision

Set the "DatetimeFractionalSecondPrecision" attribute of this object to the specified value.

setEncodeAnonSequenceInChoice

Set the "EncodeAnonSequenceInChoice" attribute of this object to the specified value.

setEncodeEmptyArrays

Set the "EncodeEmptyArrays" attribute of this object to the specified value.

setEncodeInfAndNaNAsStrings

Set the "EncodeInfAndNaNAsStrings" attribute of this object to the specified value.

setEncodeNullElements

Set the "EncodeNullElements" attribute of this object to the specified value.

setEncodeQuotedDecimal64

Set the "EncodeQuotedDecimal64" attribute of this object to the specified value.

setEncodingStyle

setEncodingStyle overloads

setEscapeForwardSlash

Set the "EscapeForwardSlash" attribute of this object to the specified value.

setInitialIndentLevel

Set the "InitialIndentLevel" attribute of this object to the specified value.

setMaxDoublePrecision

Set the "MaxDoublePrecision" attribute of this object to the specified value.

setMaxFloatPrecision

Set the "MaxFloatPrecision" attribute of this object to the specified value.

setSpacesPerLevel

Set the "SpacesPerLevel" attribute of this object to the specified value.

spacesPerLevel

Return a reference to the non‐modifiable "SpacesPerLevel" attribute of this object.

Static Member Functions

Name

Description

lookupAttributeInfo

lookupAttributeInfo overloads

Static Data Members

Name

Description

ATTRIBUTE_INFO_ARRAY

Attribute metadata for this options type.

CLASS_NAME

Name of this class.

DEFAULT_INITIALIZER_DATETIME_FRACTIONAL_SECOND_PRECISION

Default value for the datetimeFractionalSecondPrecision attribute.

DEFAULT_INITIALIZER_ENCODE_ANON_SEQUENCE_IN_CHOICE

Default value for the encodeAnonSequenceInChoice attribute.

DEFAULT_INITIALIZER_ENCODE_EMPTY_ARRAYS

Default value for the encodeEmptyArrays attribute.

DEFAULT_INITIALIZER_ENCODE_INF_AND_NA_N_AS_STRINGS

Default value for the encodeInfAndNaNAsStrings attribute.

DEFAULT_INITIALIZER_ENCODE_NULL_ELEMENTS

Default value for the encodeNullElements attribute.

DEFAULT_INITIALIZER_ENCODE_QUOTED_DECIMAL64

Default value for the encodeQuotedDecimal64 attribute.

DEFAULT_INITIALIZER_ENCODING_STYLE

Default value for the encodingStyle attribute.

DEFAULT_INITIALIZER_ESCAPE_FORWARD_SLASH

Default value for the escapeForwardSlash attribute.

DEFAULT_INITIALIZER_INITIAL_INDENT_LEVEL

Default value for the initialIndentLevel attribute.

DEFAULT_INITIALIZER_MAX_DOUBLE_PRECISION

Default value for the maxDoublePrecision attribute.

DEFAULT_INITIALIZER_MAX_FLOAT_PRECISION

Default value for the maxFloatPrecision attribute.

DEFAULT_INITIALIZER_SPACES_PER_LEVEL

Default value for the spacesPerLevel attribute.

Non-Member Functions

Name

Description

operator!=

Return true if the specified lhs and rhs attribute objects do not have the same value, and false otherwise. Two attribute objects do not have the same value if one or more respective attributes differ in values.

operator==

Return true if the specified lhs and rhs attribute objects have the same value, and false otherwise. Two attribute objects have the same value if each respective attribute has the same value.

Created with MrDocs