[#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::Json` object according to the invocations of the formatter's manipulators. == Synopsis Declared in `<baljsn_jsonformatter.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- class JsonFormatter; ---- == Type Aliases [cols="1,4"] |=== | Name| Description | xref:BloombergLP/baljsn/JsonFormatter/allocator_type.adoc[`allocator_type`] | Type of the allocator used to supply memory. |=== == 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. Optionally specify an `allocator` (e.g., the address of a `bslma::Allocator` object) to supply memory; otherwise, the default allocator is used. The behavior is undefined unless `json‐>isNull()`. | xref:BloombergLP/baljsn/JsonFormatter/addArrayElementSeparator.adoc[`addArrayElementSeparator`] | No‐op. | xref:BloombergLP/baljsn/JsonFormatter/closeArray.adoc[`closeArray`] | Indicate that there are no more elements to be added to the current array. The specified `formatAsEmptyArray` is ignored; arrays are unconditionally formatted. | xref:BloombergLP/baljsn/JsonFormatter/closeMember.adoc[`closeMember`] | Indicate that there are no more members to be added to the current object. | xref:BloombergLP/baljsn/JsonFormatter/closeObject.adoc[`closeObject`] | Indicate that there are no more members to be added to the current object. | xref:BloombergLP/baljsn/JsonFormatter/dumpStack.adoc[`dumpStack`] | Print the internal stack of `Status` objects to standard output in lifo order. Each line of output consists of: | xref:BloombergLP/baljsn/JsonFormatter/get_allocator.adoc[`get_allocator`] | Return the allocator used by this object to supply memory. Note that if no allocator was supplied at construction the default allocator in effect at construction is used. | xref:BloombergLP/baljsn/JsonFormatter/nestingDepth.adoc[`nestingDepth`] | No‐op. Return 0. | xref:BloombergLP/baljsn/JsonFormatter/openArray.adoc[`openArray`] | Create a new array. Subsequently created elements will land in this array (in order of creation) until `closeArray` is called. The elements can be created by `putValue`/`putNullValue`/`openObject`/`openArray`. The specified `formatAsEmptyArray` is ignored; arrays are unconditionally formatted. | xref:BloombergLP/baljsn/JsonFormatter/openMember.adoc[`openMember`] | Create a new object member having the specified `name`. Return 0 on success and a non‐zero value otherwise. An error is returned if `name` contains a non‐UTF8 character. | xref:BloombergLP/baljsn/JsonFormatter/openObject.adoc[`openObject`] | Create a new object (set of name/value pairs also know as "members"). Note subsequently created members will land in this object until `closeObject` is called. | xref:BloombergLP/baljsn/JsonFormatter/putNullValue.adoc[`putNullValue`] | Set the value of the current array element or object value ‐‐ depending on the context ‐‐ to `bdljsn::JsonNull`. Return 0 on success and a non‐zero value otherwise. An error is returned when `putNullValue` is called in an unexpected context. | xref:BloombergLP/baljsn/JsonFormatter/putValue.adoc[`putValue`] | Set the value of the current scalar, array element, or object value ‐‐ depending on the context ‐‐ to the specified `value` of (template parameter) `TYPE`. The specified `options` is ignored except: * `encodeInfAndNaNAsStrings` when `TYPE` is a floating point type. * `datetimeFractionalSecondPrecision` when `TYPE` features a datetime or time attribute. Return 0 on success and a non‐zero value otherwise. Errors are returned if `value` is disallowed for `bdljsn::Json` objects: * `value` is a string type and contains a non‐UTF8 character. * `value` is a floating point type, is INF or NaN, and `false == encodeInfAndNanAsStrings`. |=== == Data Members [cols="1,4"] |=== | Name| Description | xref:BloombergLP/baljsn/JsonFormatter/d_allocator.adoc[`d_allocator`] | Allocator used to supply memory. | xref:BloombergLP/baljsn/JsonFormatter/d_stack.adoc[`d_stack`] | The `d_stack` data member. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#