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

`encode` overloads

== Synopses

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

Encode `value` as JSON onto `stream` using default options&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class TYPE&gt;
int
xref:BloombergLP/baljsn/Encoder/encode-0e7.adoc[encode](
    std::ostream& stream,
    TYPE const& value);
----

[.small]#xref:BloombergLP/baljsn/Encoder/encode-0e7.adoc[_» more&period;&period;&period;_]#

Encode the specified `value` of (template parameter) `TYPE` into the specified `streamBuf`&period; Return 0 on success, and a non&hyphen;zero value otherwise&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class TYPE&gt;
int
xref:BloombergLP/baljsn/Encoder/encode-0ea.adoc[encode](
    std::streambuf* streamBuf,
    TYPE const& value);
----

[.small]#xref:BloombergLP/baljsn/Encoder/encode-0ea.adoc[_» more&period;&period;&period;_]#

Encode `value` as JSON onto `stream` using `options`&period;


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

[.small]#xref:BloombergLP/baljsn/Encoder/encode-09.adoc[_» more&period;&period;&period;_]#

Same as the preceding overload, accepting a nullable `options` pointer&period;


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

[.small]#xref:BloombergLP/baljsn/Encoder/encode-05.adoc[_» more&period;&period;&period;_]#

Encode `value` as JSON onto `streamBuf` using `options`&period;


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

[.small]#xref:BloombergLP/baljsn/Encoder/encode-06.adoc[_» more&period;&period;&period;_]#

Same as the preceding overload, accepting a nullable `options` pointer&period;


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

[.small]#xref:BloombergLP/baljsn/Encoder/encode-00.adoc[_» more&period;&period;&period;_]#

== Return Value

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

== Parameters

[cols="1,4"]
|===
| Name| Description
| *stream*
| output stream for JSON
| *value*
| value to encode
| *streamBuf*
| output buffer for JSON
| *options*
| encoding options
|===


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