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

Create a `Formatter` that writes JSON text to the specified `stream`&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
Formatter(
    std::ostream& stream,
    bool usePrettyStyle = false,
    int initialIndentLevel = 0,
    int spacesPerLevel = 0,
    xref:BloombergLP/bslma/Allocator.adoc[bslma::Allocator]* basicAllocator = 0);
----

== Description

Create a `Formatter` object using the specified `stream`&period; Optionally specify `usePrettyStyle` to inform the formatter whether the pretty encoding style should be used when writing data&period; If `usePrettyStyle` is not specified then the data is written in a compact style&period; If `usePrettyStyle` is specified, additionally specify `initialIndentLevel` and `spacesPerLevel` to provide the initial indentation level and spaces per level at which the data should be formatted&period; If `initialIndentLevel` or `spacesPerLevel` is not specified then an initial value of `0` is used for both parameters&period; If `usePrettyStyle` is `false` then `initialIndentLevel` and `spacesPerLevel` are both ignored&period; Optionally specify `escapeForwardSlash`&period; If `escapeForwardSlash` is specified as `false`, `&sol;` characters will be formatted as&hyphen;is, otherwise, they will be rendered with a leading backslash, as &quot;&bsol;&sol;&quot;&period; Optionally specify a `basicAllocator` used to supply memory&period; If `basicAllocator` is 0, the currently installed default allocator is used&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *stream*
| output stream for formatted JSON
| *usePrettyStyle*
| whether to use pretty encoding style
| *initialIndentLevel*
| starting indentation level for pretty style
| *spacesPerLevel*
| spaces per indentation level for pretty style
| *basicAllocator*
| memory allocator&semi; null uses the default
|===


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