[#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). == Synopsis Declared in `<baljsn_simpleformatter.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- class SimpleFormatter; ---- == Description This class has an interface that's easier to use than that of `baljsn::Formatter`, and generates more correctly‐formatted `pretty` output. == Enums [cols="1,4"] |=== | Name| Description | xref:BloombergLP/baljsn/SimpleFormatter/ArrayFormattingStyle.adoc[`ArrayFormattingStyle`] | This `enum` lists all possible array formatting styles. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/baljsn/SimpleFormatter/2constructor-069.adoc[`SimpleFormatter`] [.small]#[constructor]# | Constructors | xref:BloombergLP/baljsn/SimpleFormatter/2destructor.adoc[`~SimpleFormatter`] [.small]#[destructor]# | Destroy this object. Note that correct JSON has been generated if the `isCompleteJSON()` call returns `true`. | xref:BloombergLP/baljsn/SimpleFormatter/addMemberName.adoc[`addMemberName`] | Print onto the stream supplied at construction the specified `name` in double‐quotes, preceded, if necessary, by a comma, and followed by a `:`. The behavior is undefined unless `isNameNeeded()` is `true`. 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. | 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. Note that if no allocator was supplied at construction the currently installed default allocator is used. | 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 "array" in JSON). Optionally specify `formattingStyle` denoting if the array being closed should be formatted as an empty array. If `formattingStyle` is not specified then the array being closed is formatted as a regular array having elements. The behavior is undefined if `isFormattingArray()` is `false`. 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. | 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 "object" in JSON). The behavior is undefined unless `isNameNeeded()` is `true`. | xref:BloombergLP/baljsn/SimpleFormatter/isCompleteJSON.adoc[`isCompleteJSON`] | Return `true` if this `SimpleFormatter` has formatted a complete JSON object, where all `open*` calls have been balanced by their corresponding `close*` calls. Note that a default‐constructed `SimpleFormatter` will return `false` ‐ an empty string is not valid JSON. | xref:BloombergLP/baljsn/SimpleFormatter/isFormattingArray.adoc[`isFormattingArray`] | Return `true` if this `SimpleFormatter` is currently formatting an array and `false` otherwise. It is formatting an array if the last `open*` method overload (`openArray` or `openObject`) called on this `SimpleFormatter` for which the corresponding `close*` method (respectively, `closeArray` or `closeObject`) was `openArray`. If `isFormattingArray()` is `true`, then `isFormattingObject()` is `false`. Note that both can be `false`, at the `top‐level` initial scope before anything is added/opened or after the first `open*` call has been closed' | xref:BloombergLP/baljsn/SimpleFormatter/isFormattingObject.adoc[`isFormattingObject`] | Return `true` if this `SimpleFormatter` is currently formatting an object scope and `false` otherwise. It is formatting an object scope if the last `open*` method overload (`openArray` or `openObject`) called on this `SimpleFormatter` for which the corresponding `close*` method (respectively, `closeArray` or `closeObject`) was `openObject`. If `isFormattingObject()` is `true`, then `isFormattingArray()` is `false`. Note that both can be `false`, at the `top‐level` initial scope before anything is added/opened or after the first `open*` call has been closed' JSON. | xref:BloombergLP/baljsn/SimpleFormatter/isNameNeeded.adoc[`isNameNeeded`] | Return `true` if a subsequent attempt to add a value must supply a `name`, and `false` otherwise. This will be `true` if `isFormattingObject()` is `true`, and `addMemberName()` was not the most recently called manipulator. 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. | 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<SimpleFormatter, UsesBslmaAllocator>`] | `SimpleFormatter` uses a `bslma` allocator. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#