[#BloombergLP-baljsn-EncoderOptions]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/baljsn.adoc[baljsn]::EncoderOptions
:relfileprefix: ../../
:mrdocs:

Options for performing JSON encoding&period;

== Synopsis

Declared in `&lt;baljsn&lowbar;encoderoptions&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class EncoderOptions;
----

== Description

`EncodingStyle` is either `COMPACT` or `PRETTY`&period; If `EncodingStyle` is `COMPACT`, no whitespace will be added between elements&period; If encoding style is `PRETTY`, then the `InitialIndentLevel` and `SpacesPerLevel` parameters are used to specify the formatting of the output&period; Note that `InitialIndentLevel` and `SpacesPerLevel` are ignored when `EncodingStyle` is `COMPACT` (this is the default)&period; The `EncodeEmptyArrays` and `EncodeNullElements` encode empty array and null elements respectively&period; By default empty array and null elements are not encoded&period; The `EncodeInfAndNaNAsStrings` attribute provides users the option to encode `Infinity` and `NaN` floating point values as strings&period; These values do not have a valid JSON representation and by default such value will result in an encoding error&period; The `DatetimeFractionalSecondPrecision` specifies the precision of milliseconds printed with date time values&period; By default a precision of `3` decimal places is used&period; The `MaxFloatPrecision` and `MaxDoublePrecision` attributes allow specifying the maximum precision for `float` and `double` values&period; 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&period; We recommend against setting these options&colon; they were provided prior to the current default behavior (of choosing the shortest presentation that can be restored to the original value) being available&period;

== Enums

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/baljsn/EncoderOptions/_04enum-07.adoc[`Unnamed enum`] 
| Attribute identifier constants&period;
| xref:BloombergLP/baljsn/EncoderOptions/_04enum-0e.adoc[`Unnamed enum`] 
| Attribute count constants&period;
| xref:BloombergLP/baljsn/EncoderOptions/_04enum-09.adoc[`Unnamed enum`] 
| Attribute index constants&period;
| xref:BloombergLP/baljsn/EncoderOptions/EncodingStyle-0f.adoc[`EncodingStyle`] 
| Encoding style enumerators for backwards compatibility&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/baljsn/EncoderOptions/2constructor-02.adoc[`EncoderOptions`]         [.small]#[constructor]#
| Constructors
| xref:BloombergLP/baljsn/EncoderOptions/2destructor.adoc[`&#126;EncoderOptions`] [.small]#[destructor]#
| Destroy this object&period;
| xref:BloombergLP/baljsn/EncoderOptions/operator_assign.adoc[`operator&equals;`] 
| Assign to this object the value of the specified `rhs` object&period;
| xref:BloombergLP/baljsn/EncoderOptions/accessAttribute-02.adoc[`accessAttribute`] 
| `accessAttribute` overloads
| xref:BloombergLP/baljsn/EncoderOptions/accessAttributes.adoc[`accessAttributes`] 
| Invoke `accessor` sequentially on each non&hyphen;modifiable attribute&period;
| xref:BloombergLP/baljsn/EncoderOptions/datetimeFractionalSecondPrecision.adoc[`datetimeFractionalSecondPrecision`] 
| Return a reference to the non&hyphen;modifiable &quot;DatetimeFractionalSecondPrecision&quot; attribute of this object&period;
| xref:BloombergLP/baljsn/EncoderOptions/encodeAnonSequenceInChoice.adoc[`encodeAnonSequenceInChoice`] 
| Return the value of the &quot;EncodeAnonSequenceInChoice&quot; attribute of this object&period;
| xref:BloombergLP/baljsn/EncoderOptions/encodeEmptyArrays.adoc[`encodeEmptyArrays`] 
| Return the non&hyphen;modifiable &quot;EncodeEmptyArrays&quot; attribute of this object&period;
| xref:BloombergLP/baljsn/EncoderOptions/encodeInfAndNaNAsStrings.adoc[`encodeInfAndNaNAsStrings`] 
| Return a reference to the non&hyphen;modifiable &quot;EncodeInfAndNaNAsStrings&quot; attribute of this object&period;
| xref:BloombergLP/baljsn/EncoderOptions/encodeNullElements.adoc[`encodeNullElements`] 
| Return a reference to the non&hyphen;modifiable &quot;EncodeNullElements&quot; attribute of this object&period;
| xref:BloombergLP/baljsn/EncoderOptions/encodeQuotedDecimal64.adoc[`encodeQuotedDecimal64`] 
| Return the value of the &quot;EncodeQuotedDecimal64&quot; attribute of this object&period;
| xref:BloombergLP/baljsn/EncoderOptions/encodingStyle-04.adoc[`encodingStyle`] 
| Return a reference to the non&hyphen;modifiable &quot;EncodingStyle&quot; attribute of this object&period;
| xref:BloombergLP/baljsn/EncoderOptions/escapeForwardSlash.adoc[`escapeForwardSlash`] 
| Return the value of the &quot;EscapeForwardSlash&quot; attribute of this object&period;
| xref:BloombergLP/baljsn/EncoderOptions/initialIndentLevel.adoc[`initialIndentLevel`] 
| Return a reference to the non&hyphen;modifiable &quot;InitialIndentLevel&quot; attribute of this object&period;
| xref:BloombergLP/baljsn/EncoderOptions/manipulateAttribute-03.adoc[`manipulateAttribute`] 
| `manipulateAttribute` overloads
| xref:BloombergLP/baljsn/EncoderOptions/manipulateAttributes.adoc[`manipulateAttributes`] 
| Invoke `manipulator` sequentially on each modifiable attribute&period;
| xref:BloombergLP/baljsn/EncoderOptions/maxDoublePrecision.adoc[`maxDoublePrecision`] 
| Return a reference to the non&hyphen;modifiable &quot;MaxDoublePrecision&quot; attribute of this object&period;
| xref:BloombergLP/baljsn/EncoderOptions/maxFloatPrecision.adoc[`maxFloatPrecision`] 
| Return a reference to the non&hyphen;modifiable &quot;MaxFloatPrecision&quot; attribute of this object&period;
| xref:BloombergLP/baljsn/EncoderOptions/print.adoc[`print`] 
| Format this object to the specified output `stream`&period;
| xref:BloombergLP/baljsn/EncoderOptions/reset.adoc[`reset`] 
| Reset this object to the default value (i&period;e&period;, its value upon default construction)&period;
| xref:BloombergLP/baljsn/EncoderOptions/setDatetimeFractionalSecondPrecision.adoc[`setDatetimeFractionalSecondPrecision`] 
| Set the &quot;DatetimeFractionalSecondPrecision&quot; attribute of this object&period;
| xref:BloombergLP/baljsn/EncoderOptions/setEncodeAnonSequenceInChoice.adoc[`setEncodeAnonSequenceInChoice`] 
| Set the &quot;EncodeAnonSequenceInChoice&quot; attribute of this object to the specified `value`&period;
| xref:BloombergLP/baljsn/EncoderOptions/setEncodeEmptyArrays.adoc[`setEncodeEmptyArrays`] 
| Set the &quot;EncodeEmptyArrays&quot; attribute of this object to the specified `value`&period;
| xref:BloombergLP/baljsn/EncoderOptions/setEncodeInfAndNaNAsStrings.adoc[`setEncodeInfAndNaNAsStrings`] 
| Set the &quot;EncodeInfAndNaNAsStrings&quot; attribute of this object to the specified `value`&period;
| xref:BloombergLP/baljsn/EncoderOptions/setEncodeNullElements.adoc[`setEncodeNullElements`] 
| Set the &quot;EncodeNullElements&quot; attribute to the specified `value`&period;
| xref:BloombergLP/baljsn/EncoderOptions/setEncodeQuotedDecimal64.adoc[`setEncodeQuotedDecimal64`] 
| Set the &quot;EncodeQuotedDecimal64&quot; attribute of this object to the specified `value`&period;
| xref:BloombergLP/baljsn/EncoderOptions/setEncodingStyle-04.adoc[`setEncodingStyle`] 
| `setEncodingStyle` overloads
| xref:BloombergLP/baljsn/EncoderOptions/setEscapeForwardSlash.adoc[`setEscapeForwardSlash`] 
| Set the &quot;EscapeForwardSlash&quot; attribute of this object to the specified `value`&period;
| xref:BloombergLP/baljsn/EncoderOptions/setInitialIndentLevel.adoc[`setInitialIndentLevel`] 
| Set the &quot;InitialIndentLevel&quot; attribute of this object to the specified `value`&period;
| xref:BloombergLP/baljsn/EncoderOptions/setMaxDoublePrecision.adoc[`setMaxDoublePrecision`] 
| Set the &quot;MaxDoublePrecision&quot; attribute of this object to the specified `value`&period;
| xref:BloombergLP/baljsn/EncoderOptions/setMaxFloatPrecision.adoc[`setMaxFloatPrecision`] 
| Set the &quot;MaxFloatPrecision&quot; attribute of this object to the specified `value`&period;
| xref:BloombergLP/baljsn/EncoderOptions/setSpacesPerLevel.adoc[`setSpacesPerLevel`] 
| Set the &quot;SpacesPerLevel&quot; attribute of this object to the specified `value`&period;
| xref:BloombergLP/baljsn/EncoderOptions/spacesPerLevel.adoc[`spacesPerLevel`] 
| Return a reference to the non&hyphen;modifiable &quot;SpacesPerLevel&quot; attribute of this object&period;
|===


== Static Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/baljsn/EncoderOptions/lookupAttributeInfo-02.adoc[`lookupAttributeInfo`] 
| `lookupAttributeInfo` overloads
|===


== Static Data Members

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/baljsn/EncoderOptions/ATTRIBUTE_INFO_ARRAY.adoc[`ATTRIBUTE&lowbar;INFO&lowbar;ARRAY`] 
| Attribute metadata for this options type&period;
| xref:BloombergLP/baljsn/EncoderOptions/CLASS_NAME.adoc[`CLASS&lowbar;NAME`] 
| Name of this class&period;
| xref:BloombergLP/baljsn/EncoderOptions/DEFAULT_INITIALIZER_DATETIME_FRACTIONAL_SECOND_PRECISION.adoc[`DEFAULT&lowbar;INITIALIZER&lowbar;DATETIME&lowbar;FRACTIONAL&lowbar;SECOND&lowbar;PRECISION`] 
| Default value for the `datetimeFractionalSecondPrecision` attribute&period;
| xref:BloombergLP/baljsn/EncoderOptions/DEFAULT_INITIALIZER_ENCODE_ANON_SEQUENCE_IN_CHOICE.adoc[`DEFAULT&lowbar;INITIALIZER&lowbar;ENCODE&lowbar;ANON&lowbar;SEQUENCE&lowbar;IN&lowbar;CHOICE`] 
| Default value for the `encodeAnonSequenceInChoice` attribute&period;
| xref:BloombergLP/baljsn/EncoderOptions/DEFAULT_INITIALIZER_ENCODE_EMPTY_ARRAYS.adoc[`DEFAULT&lowbar;INITIALIZER&lowbar;ENCODE&lowbar;EMPTY&lowbar;ARRAYS`] 
| Default value for the `encodeEmptyArrays` attribute&period;
| xref:BloombergLP/baljsn/EncoderOptions/DEFAULT_INITIALIZER_ENCODE_INF_AND_NA_N_AS_STRINGS.adoc[`DEFAULT&lowbar;INITIALIZER&lowbar;ENCODE&lowbar;INF&lowbar;AND&lowbar;NA&lowbar;N&lowbar;AS&lowbar;STRINGS`] 
| Default value for the `encodeInfAndNaNAsStrings` attribute&period;
| xref:BloombergLP/baljsn/EncoderOptions/DEFAULT_INITIALIZER_ENCODE_NULL_ELEMENTS.adoc[`DEFAULT&lowbar;INITIALIZER&lowbar;ENCODE&lowbar;NULL&lowbar;ELEMENTS`] 
| Default value for the `encodeNullElements` attribute&period;
| xref:BloombergLP/baljsn/EncoderOptions/DEFAULT_INITIALIZER_ENCODE_QUOTED_DECIMAL64.adoc[`DEFAULT&lowbar;INITIALIZER&lowbar;ENCODE&lowbar;QUOTED&lowbar;DECIMAL64`] 
| Default value for the `encodeQuotedDecimal64` attribute&period;
| xref:BloombergLP/baljsn/EncoderOptions/DEFAULT_INITIALIZER_ENCODING_STYLE.adoc[`DEFAULT&lowbar;INITIALIZER&lowbar;ENCODING&lowbar;STYLE`] 
| Default value for the `encodingStyle` attribute&period;
| xref:BloombergLP/baljsn/EncoderOptions/DEFAULT_INITIALIZER_ESCAPE_FORWARD_SLASH.adoc[`DEFAULT&lowbar;INITIALIZER&lowbar;ESCAPE&lowbar;FORWARD&lowbar;SLASH`] 
| Default value for the `escapeForwardSlash` attribute&period;
| xref:BloombergLP/baljsn/EncoderOptions/DEFAULT_INITIALIZER_INITIAL_INDENT_LEVEL.adoc[`DEFAULT&lowbar;INITIALIZER&lowbar;INITIAL&lowbar;INDENT&lowbar;LEVEL`] 
| Default value for the `initialIndentLevel` attribute&period;
| xref:BloombergLP/baljsn/EncoderOptions/DEFAULT_INITIALIZER_MAX_DOUBLE_PRECISION.adoc[`DEFAULT&lowbar;INITIALIZER&lowbar;MAX&lowbar;DOUBLE&lowbar;PRECISION`] 
| Default value for the `maxDoublePrecision` attribute&period;
| xref:BloombergLP/baljsn/EncoderOptions/DEFAULT_INITIALIZER_MAX_FLOAT_PRECISION.adoc[`DEFAULT&lowbar;INITIALIZER&lowbar;MAX&lowbar;FLOAT&lowbar;PRECISION`] 
| Default value for the `maxFloatPrecision` attribute&period;
| xref:BloombergLP/baljsn/EncoderOptions/DEFAULT_INITIALIZER_SPACES_PER_LEVEL.adoc[`DEFAULT&lowbar;INITIALIZER&lowbar;SPACES&lowbar;PER&lowbar;LEVEL`] 
| Default value for the `spacesPerLevel` attribute&period;
|===


== Non-Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/baljsn/operator_not_eq-085.adoc[`operator!&equals;`]
| Return `true` if the specified `lhs` and `rhs` do not have the same value&period;
| xref:BloombergLP/baljsn/operator_eq-060.adoc[`operator&equals;&equals;`]
| Return `true` if the specified `lhs` and `rhs` have the same value&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
