[#BloombergLP-ball-RecordJsonFormatter]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/ball.adoc[ball]::RecordJsonFormatter
:relfileprefix: ../../
:mrdocs:

This class provides a function object that formats a log record as JSON text elements and renders them to an output stream&period; The overloaded `operator()` provided by the class formats log record according to a message format specification supplied either by `setJsonFormat` or `setSimplifiedFormat` manipulator or the default format installed by the constructor) and outputs the result to the stream&period; While this functor type is designed to match the function signature expected by many concrete `ball&colon;&colon;Observer` implementations that publish log records (for example, see `ball&colon;&colon;FileObserver2&colon;&colon;setLogFileFunctor`) it is advised to use the more flexible scheme&hyphen;based format selection provided now by every BDE&hyphen;made observer&period;

== Synopsis

Declared in `&lt;ball&lowbar;recordjsonformatter&period;h&gt;`

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

== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/ball/RecordJsonFormatter/FieldFormatters.adoc[`FieldFormatters`] 
| `FieldFormatters` is an alias for a vector of the `RecordJsonFormatter&lowbar;FieldFormatter` objects, each of which is initialized from the format specification and responsible for rendering one field of a `ball&colon;&colon;Record` to the output JSON stream&period;
| xref:BloombergLP/ball/RecordJsonFormatter/allocator_type.adoc[`allocator&lowbar;type`] 
| This `typedef` is an alias for the allocator used by this object&period;
|===


== Enums

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/ball/RecordJsonFormatter/SpecSyntax.adoc[`SpecSyntax`] 
| Enumerator to determine the syntax of the specification string&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/ball/RecordJsonFormatter/2constructor-04.adoc[`RecordJsonFormatter`]         [.small]#[constructor]#
| Constructors
| xref:BloombergLP/ball/RecordJsonFormatter/2destructor.adoc[`&#126;RecordJsonFormatter`] [.small]#[destructor]#
| Destroy this object&period;
| xref:BloombergLP/ball/RecordJsonFormatter/operator_assign-01.adoc[`operator&equals;`] 
| Assignment operators
| xref:BloombergLP/ball/RecordJsonFormatter/allocator.adoc[`allocator`]  [.small]#[deprecated]#
| DEPRECATED&colon; Use `get&lowbar;allocator()&period;mechanism()` instead&period;
| xref:BloombergLP/ball/RecordJsonFormatter/format.adoc[`format`] 
| Return the message format specification of this record JSON formatter&period; See &lcub;`Record Format Specification`&rcub;&period; Note that the syntax of this string depends on `formatSyntax()`&period;
| xref:BloombergLP/ball/RecordJsonFormatter/formatSyntax.adoc[`formatSyntax`] 
| Return the message format specification syntax of this record JSON formatter&period; See &lcub;`Record Format Specification`&rcub;&period;
| xref:BloombergLP/ball/RecordJsonFormatter/get_allocator.adoc[`get&lowbar;allocator`] 
| Return the allocator used by this object to supply memory&period;
| xref:BloombergLP/ball/RecordJsonFormatter/operator_call.adoc[`operator()`] 
| Format the specified `record` according to the current `format` and `recordSeparator` to the specified `stream`&period;
| xref:BloombergLP/ball/RecordJsonFormatter/recordSeparator.adoc[`recordSeparator`] 
| Return the record separator of this record JSON formatter&period;
| xref:BloombergLP/ball/RecordJsonFormatter/setFormat.adoc[`setFormat`] 
| DEPRECATED&colon; Use `setJsonFormat` instead&period;
| xref:BloombergLP/ball/RecordJsonFormatter/setJsonFormat.adoc[`setJsonFormat`] 
| Set the message format specification (see &lcub;&grave;Record Format Specification&grave;&rcub;) of this record JSON formatter to the specified JSON&hyphen;syntax `format`&period; Return 0 on success, and a non&hyphen;zero value otherwise (if `format` is not valid JSON _or_ not a JSON conforming to the expected schema)&period; Note that this is the method used by the `json&colon;&sol;&sol;` scheme&period;
| xref:BloombergLP/ball/RecordJsonFormatter/setRecordSeparator.adoc[`setRecordSeparator`] 
| Set the record separator for this record JSON formatter to the specified `recordSeparator`&period; The `recordSeparator` will be printed by each invocation of `operator()` after the formatted record&period; The default is a single newline character, &quot;n&quot;&period;
| xref:BloombergLP/ball/RecordJsonFormatter/setSimplifiedFormat.adoc[`setSimplifiedFormat`] 
| Parse the simplified format specification (see &lcub;&grave;Simplified Record Format Specification`&rcub;) in the specified `format&grave; and configure this formatter accordingly&period; Return 0 on success, and a non&hyphen;zero value otherwise&period;
| xref:BloombergLP/ball/RecordJsonFormatter/setTimezoneDefault.adoc[`setTimezoneDefault`] 
| Set the time zone default for every &quot;timestamp&quot; output without a timezone specified in the format string to the specified `timezoneDefault`&period; Note that this method reapplies the current format specification to update all timestamp formatters&period;
| xref:BloombergLP/ball/RecordJsonFormatter/timezoneDefault.adoc[`timezoneDefault`] 
| Get the time zone default setting&period;
|===


== Static Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/ball/RecordJsonFormatter/loadJsonSchemeFormatter.adoc[`loadJsonSchemeFormatter`] 
| This class method configures a formatter for the &quot;json&quot; scheme using the specified `format` and `formatOptions` and if successful loads it into the specified `output` and returns zero&period; In case configuration fails a non&hyphen;zero value is returned and `output` is not modified&period;
| xref:BloombergLP/ball/RecordJsonFormatter/loadQjsonSchemeFormatter.adoc[`loadQjsonSchemeFormatter`] 
| This class method configures a formatter for the &quot;qjson&quot; scheme using the specified `format` and `formatOptions` and if successful loads it into the specified `output` and returns zero&period; In case configuration fails a non&hyphen;zero value is returned and `output` is not modified&period;
|===


== Non-Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/ball/operator_not_eq-0c.adoc[`operator!&equals;`]
| Return `true` if the specified `lhs` and `rhs` record formatters do not have the same value, and `false` otherwise&period; Two record formatters differ in value if their format syntax, format specifications, timezone defaults, or record separators differ&period;
| xref:BloombergLP/ball/operator_eq-0f06.adoc[`operator&equals;&equals;`]
| Return `true` if the specified `lhs` and `rhs` record formatters have the same value, and `false` otherwise&period; Two record formatters have the same value if they have the same format syntax, format specification, timezone default, and record separator&period;
|===


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