[#BloombergLP-baljsn-EncodeImplUtil-encode-0b1]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/baljsn.adoc[baljsn]::xref:BloombergLP/baljsn/EncodeImplUtil.adoc[EncodeImplUtil]::encode
:relfileprefix: ../../../
:mrdocs:

Encode the JSON representation of `value` to `jsonStream`, logging errors to `logStream`&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class TYPE&gt;
static
int
encode(
    std::ostream* logStream,
    std::ostream* jsonStream,
    TYPE const& value,
    xref:BloombergLP/baljsn/EncoderOptions.adoc[EncoderOptions] const& options = EncoderOptions());
----

== Description

Encode the JSON representation of the specified `value` to the specified `jsonStream`&period; If this operation is not successful, load an unspecified, human&hyphen;readable description of the error condition to the specified `logStream`&period; Optionally specify `options` to configure aspects of the JSON representation of the `value`&period; If `options` is not specified, the default `EncoderOptions` value is used&period; Return 0 on success, and a non&hyphen;zero value otherwise&period; The behavior is undefined unless the specified `TYPE` satisfies both the static and dynamic requirements of one `bdlat` type&hyphen;category concept&period; See `baljsn&lowbar;encoderoptions` for a description of the effects, if any, of each option in the `options` on the JSON representation of the `value`&period; See the package&hyphen;level documentation of `bdlat` for an introduction to the requirements of `bdlat` type&hyphen;category concepts&period;

== Return Value

0 on success, and a non&hyphen;zero value otherwise

== Parameters

[cols="1,4"]
|===
| Name| Description
| *logStream*
| stream for human&hyphen;readable error descriptions
| *jsonStream*
| stream that receives the JSON representation
| *value*
| value to encode
| *options*
| encoding options
|===


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