[#BloombergLP-baljsn-SimpleFormatter]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/baljsn.adoc[baljsn]::SimpleFormatter
: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;simpleformatter&period;h&gt;`

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

== Description

This class has an interface that&apos;s easier to use than that of `baljsn&colon;&colon;Formatter`, and generates more correctly&hyphen;formatted `pretty` output&period;

== Enums

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/baljsn/SimpleFormatter/ArrayFormattingStyle.adoc[`ArrayFormattingStyle`] 
| This `enum` lists all possible array formatting styles&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/baljsn/SimpleFormatter/2constructor-069.adoc[`SimpleFormatter`]         [.small]#[constructor]#
| Constructors
| xref:BloombergLP/baljsn/SimpleFormatter/2destructor.adoc[`&#126;SimpleFormatter`] [.small]#[destructor]#
| Destroy this object&period; Note that correct JSON has been generated if the `isCompleteJSON()` call returns `true`&period;
| xref:BloombergLP/baljsn/SimpleFormatter/addMemberName.adoc[`addMemberName`] 
| Print onto the stream supplied at construction the specified `name` in double&hyphen;quotes, preceded, if necessary, by a comma, and followed by a `&colon;`&period; The behavior is undefined unless `isNameNeeded()` is `true`&period; After this operation, `isNameNeeded()` will be `false`, and an immediately subsequent attempt to add a value (or open an object or array) should not provide a name&period;
| xref:BloombergLP/baljsn/SimpleFormatter/addNullValue-0e8.adoc[`addNullValue`] 
| `addNullValue` overloads
| xref:BloombergLP/baljsn/SimpleFormatter/addValue-05.adoc[`addValue`] 
| `addValue` overloads
| xref:BloombergLP/baljsn/SimpleFormatter/allocator.adoc[`allocator`] 
| Return the allocator used by this object to supply memory&period; Note that if no allocator was supplied at construction the currently installed default allocator is used&period;
| xref:BloombergLP/baljsn/SimpleFormatter/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 `formattingStyle` denoting if the array being closed should be formatted as an empty array&period; If `formattingStyle` is not specified then the array being closed is formatted as a regular array having elements&period; The behavior is undefined if `isFormattingArray()` is `false`&period; Note that the formatting (and as a consequence the `formattingStyle`) is relevant only if this formatter encodes in the pretty style and is ignored otherwise&period;
| xref:BloombergLP/baljsn/SimpleFormatter/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 `isNameNeeded()` is `true`&period;
| xref:BloombergLP/baljsn/SimpleFormatter/isCompleteJSON.adoc[`isCompleteJSON`] 
| Return `true` if this `SimpleFormatter` has formatted a complete JSON object, where all `open&ast;` calls have been balanced by their corresponding `close&ast;` calls&period; Note that a default&hyphen;constructed `SimpleFormatter` will return `false` &hyphen; an empty string is not valid JSON&period;
| xref:BloombergLP/baljsn/SimpleFormatter/isFormattingArray.adoc[`isFormattingArray`] 
| Return `true` if this `SimpleFormatter` is currently formatting an array and `false` otherwise&period; It is formatting an array if the last `open&ast;` method overload (`openArray` or `openObject`) called on this `SimpleFormatter` for which the corresponding `close&ast;` method (respectively, `closeArray` or `closeObject`) was `openArray`&period; If `isFormattingArray()` is `true`, then `isFormattingObject()` is `false`&period; Note that both can be `false`, at the `top&hyphen;level` initial scope before anything is added&sol;opened or after the first `open&ast;` call has been closed&apos;
| xref:BloombergLP/baljsn/SimpleFormatter/isFormattingObject.adoc[`isFormattingObject`] 
| Return `true` if this `SimpleFormatter` is currently formatting an object scope and `false` otherwise&period; It is formatting an object scope if the last `open&ast;` method overload (`openArray` or `openObject`) called on this `SimpleFormatter` for which the corresponding `close&ast;` method (respectively, `closeArray` or `closeObject`) was `openObject`&period; If `isFormattingObject()` is `true`, then `isFormattingArray()` is `false`&period; Note that both can be `false`, at the `top&hyphen;level` initial scope before anything is added&sol;opened or after the first `open&ast;` call has been closed&apos; JSON&period;
| xref:BloombergLP/baljsn/SimpleFormatter/isNameNeeded.adoc[`isNameNeeded`] 
| Return `true` if a subsequent attempt to add a value must supply a `name`, and `false` otherwise&period; This will be `true` if `isFormattingObject()` is `true`, and `addMemberName()` was not the most recently called manipulator&period; That is, a name is needed if this formatter is currently in the context of formatting the members of a JSON object, and `addMemberName` has not been called to explicitly provide a name for the next member&period;
| xref:BloombergLP/baljsn/SimpleFormatter/openArray-00.adoc[`openArray`] 
| `openArray` overloads
| xref:BloombergLP/baljsn/SimpleFormatter/openObject-0a.adoc[`openObject`] 
| `openObject` overloads
| xref:BloombergLP/baljsn/SimpleFormatter/2conversion.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration&lt;SimpleFormatter, UsesBslmaAllocator&gt;`] 
| `SimpleFormatter` uses a `bslma` allocator&period;
|===



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