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

This class implements a formatter mechanism that assembles a (potentially complicated) `bdljsn&colon;&colon;Json` object according to the invocations of the formatter&apos;s manipulators&period;

== Synopsis

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

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

== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/baljsn/JsonFormatter/allocator_type.adoc[`allocator&lowbar;type`] 
| Type of the allocator used to supply memory&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/baljsn/JsonFormatter/2constructor.adoc[`JsonFormatter`]         [.small]#[constructor]#
| Create a `JsonFormatter` object that modifies the specified `json` object in accordance with subsequent calls the formatter manipulators&period; Optionally specify an `allocator` (e&period;g&period;, the address of a `bslma&colon;&colon;Allocator` object) to supply memory&semi; otherwise, the default allocator is used&period; The behavior is undefined unless `json&hyphen;&gt;isNull()`&period;
| xref:BloombergLP/baljsn/JsonFormatter/addArrayElementSeparator.adoc[`addArrayElementSeparator`] 
| No&hyphen;op&period;
| xref:BloombergLP/baljsn/JsonFormatter/closeArray.adoc[`closeArray`] 
| Indicate that there are no more elements to be added to the current array&period; The specified `formatAsEmptyArray` is ignored&semi; arrays are unconditionally formatted&period;
| xref:BloombergLP/baljsn/JsonFormatter/closeMember.adoc[`closeMember`] 
| Indicate that there are no more members to be added to the current object&period;
| xref:BloombergLP/baljsn/JsonFormatter/closeObject.adoc[`closeObject`] 
| Indicate that there are no more members to be added to the current object&period;
| xref:BloombergLP/baljsn/JsonFormatter/dumpStack.adoc[`dumpStack`] 
| Print the internal stack of `Status` objects to standard output in lifo order&period; Each line of output consists of&colon;
| xref:BloombergLP/baljsn/JsonFormatter/get_allocator.adoc[`get&lowbar;allocator`] 
| Return the allocator used by this object to supply memory&period; Note that if no allocator was supplied at construction the default allocator in effect at construction is used&period;
| xref:BloombergLP/baljsn/JsonFormatter/nestingDepth.adoc[`nestingDepth`] 
| No&hyphen;op&period; Return 0&period;
| xref:BloombergLP/baljsn/JsonFormatter/openArray.adoc[`openArray`] 
| Create a new array&period; Subsequently created elements will land in this array (in order of creation) until `closeArray` is called&period; The elements can be created by `putValue`&sol;`putNullValue`&sol;`openObject`&sol;`openArray`&period; The specified `formatAsEmptyArray` is ignored&semi; arrays are unconditionally formatted&period;
| xref:BloombergLP/baljsn/JsonFormatter/openMember.adoc[`openMember`] 
| Create a new object member having the specified `name`&period; Return 0 on success and a non&hyphen;zero value otherwise&period; An error is returned if `name` contains a non&hyphen;UTF8 character&period;
| xref:BloombergLP/baljsn/JsonFormatter/openObject.adoc[`openObject`] 
| Create a new object (set of name&sol;value pairs also know as &quot;members&quot;)&period; Note subsequently created members will land in this object until `closeObject` is called&period;
| xref:BloombergLP/baljsn/JsonFormatter/putNullValue.adoc[`putNullValue`] 
| Set the value of the current array element or object value &hyphen;&hyphen; depending on the context &hyphen;&hyphen; to `bdljsn&colon;&colon;JsonNull`&period; Return 0 on success and a non&hyphen;zero value otherwise&period; An error is returned when `putNullValue` is called in an unexpected context&period;
| xref:BloombergLP/baljsn/JsonFormatter/putValue.adoc[`putValue`] 
| Set the value of the current scalar, array element, or object value &hyphen;&hyphen; depending on the context &hyphen;&hyphen; to the specified `value` of (template parameter) `TYPE`&period; The specified `options` is ignored except&colon; &ast; `encodeInfAndNaNAsStrings` when `TYPE` is a floating point type&period; &ast; `datetimeFractionalSecondPrecision` when `TYPE` features a datetime or time attribute&period; Return 0 on success and a non&hyphen;zero value otherwise&period; Errors are returned if `value` is disallowed for `bdljsn&colon;&colon;Json` objects&colon; &ast; `value` is a string type and contains a non&hyphen;UTF8 character&period; &ast; `value` is a floating point type, is INF or NaN, and `false &equals;&equals; encodeInfAndNanAsStrings`&period;
|===


== Data Members

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/baljsn/JsonFormatter/d_allocator.adoc[`d&lowbar;allocator`] 
| Allocator used to supply memory&period;
| xref:BloombergLP/baljsn/JsonFormatter/d_stack.adoc[`d&lowbar;stack`] 
| The `d&lowbar;stack` data member&period;
|===



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