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

This class implements a formatter providing operations for rendering JSON text elements to an output stream (supplied at construction) according to a set of formatting options (also supplied at construction)&period;

== Synopsis

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

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

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/baljsn/Formatter/2constructor-02.adoc[`Formatter`]         [.small]#[constructor]#
| Constructors
| xref:BloombergLP/baljsn/Formatter/addArrayElementSeparator.adoc[`addArrayElementSeparator`] 
| Print onto the stream supplied at construction the sequence of characters designating an array element separator (i&period;e&period;, `,`)&period; The behavior is undefined unless this `Formatter` is currently formatting a member&period;
| xref:BloombergLP/baljsn/Formatter/closeArray.adoc[`closeArray`] 
| Print onto the stream supplied at construction the sequence of characters designating the end of an array (referred to as an &quot;array&quot; in JSON)&period; Optionally specify `formatAsEmptyArray` denoting if the array being closed should be formatted as an empty array&period; If `formatAsEmptyArray` is not specified then the array being closed is formatted as an array having elements&period; The behavior is undefined unless this `Formatter` is currently formatting an array&period; Note that the formatting (and as a consequence the `formatAsEmptyArray`) is relevant only if this formatter encodes in the pretty style and is ignored otherwise&period;
| xref:BloombergLP/baljsn/Formatter/closeMember.adoc[`closeMember`] 
| Print onto the stream supplied at construction the sequence of characters designating the end of an member (referred to as a &quot;name&sol;value pair&quot; in JSON)&period; The behavior is undefined unless this `Formatter` is currently formatting a member&period;
| xref:BloombergLP/baljsn/Formatter/closeObject.adoc[`closeObject`] 
| Print onto the stream supplied at construction the sequence of characters designating the end of an object (referred to as an &quot;object&quot; in JSON)&period; The behavior is undefined unless this `Formatter` is currently formatting an object&period;
| xref:BloombergLP/baljsn/Formatter/nestingDepth.adoc[`nestingDepth`] 
| Return the number of currently open nested objects or arrays&period;
| xref:BloombergLP/baljsn/Formatter/openArray.adoc[`openArray`] 
| Print onto the stream supplied at construction the sequence of characters designating the start of an array (referred to as an &quot;array&quot; in JSON)&period; Optionally specify `formatAsEmptyArray` denoting if the array being opened should be formatted as an empty array&period; If `formatAsEmptyArray` is not specified then the array being opened is formatted as an array having elements&period; Note that the formatting (and as a consequence the `formatAsEmptyArray`) is relevant only if this formatter encodes in the pretty style and is ignored otherwise&period;
| xref:BloombergLP/baljsn/Formatter/openMember.adoc[`openMember`] 
| Print onto the stream supplied at construction the sequence of characters designating the start of a member (referred to as a &quot;name&sol;value pair&quot; in JSON) having the specified `name`&period; Return 0 on success and a non&hyphen;zero value otherwise&period;
| xref:BloombergLP/baljsn/Formatter/openObject.adoc[`openObject`] 
| Print onto the stream supplied at construction the sequence of characters designating the start of an object (referred to as an &quot;object&quot; in JSON)&period;
| xref:BloombergLP/baljsn/Formatter/putNullValue.adoc[`putNullValue`] 
| Print onto the stream supplied at construction the value corresponding to a null element&period; Return 0 on success and a non&hyphen;zero value otherwise&period;
| xref:BloombergLP/baljsn/Formatter/putValue.adoc[`putValue`] 
| Print onto the stream supplied at construction the specified `value`&period; Optionally specify `options` according which `value` should be encoded&period; Return 0 on success and a non&hyphen;zero value otherwise&period;
|===



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