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

`encode` overloads

== Synopses

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

Encode the specified `datum` as a JSON string onto the specified `stream`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
static
int
xref:BloombergLP/baljsn/DatumUtil/encode-04.adoc[encode](
    std::ostream& stream,
    xref:BloombergLP/bdld/Datum.adoc[bdld::Datum] const& datum);
----

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

Encode the specified `datum` as a JSON string into the specified `result`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
static
int
xref:BloombergLP/baljsn/DatumUtil/encode-03.adoc[encode](
    xref:bsl/string.adoc[bsl::string]* result,
    xref:BloombergLP/bdld/Datum.adoc[bdld::Datum] const& datum);
----

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

Encode `datum` as JSON into `result` as a `std&colon;&colon;pmr&colon;&colon;string`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
static
int
xref:BloombergLP/baljsn/DatumUtil/encode-08.adoc[encode](
    std::pmr::string* result,
    xref:BloombergLP/bdld/Datum.adoc[bdld::Datum] const& datum);
----

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

Encode `datum` as JSON into `result` as a `std&colon;&colon;string`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
static
int
xref:BloombergLP/baljsn/DatumUtil/encode-02f.adoc[encode](
    std::string* result,
    xref:BloombergLP/bdld/Datum.adoc[bdld::Datum] const& datum);
----

[.small]#xref:BloombergLP/baljsn/DatumUtil/encode-02f.adoc[_» more&period;&period;&period;_]#

Encode `datum` as JSON onto `stream`, using the specified `options`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
static
int
xref:BloombergLP/baljsn/DatumUtil/encode-07.adoc[encode](
    std::ostream& stream,
    xref:BloombergLP/bdld/Datum.adoc[bdld::Datum] const& datum,
    xref:BloombergLP/baljsn/DatumEncoderOptions.adoc[DatumEncoderOptions] const& options);
----

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

Encode `datum` as JSON into `result`, using the specified `options`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
static
int
xref:BloombergLP/baljsn/DatumUtil/encode-0a7.adoc[encode](
    xref:bsl/string.adoc[bsl::string]* result,
    xref:BloombergLP/bdld/Datum.adoc[bdld::Datum] const& datum,
    xref:BloombergLP/baljsn/DatumEncoderOptions.adoc[DatumEncoderOptions] const& options);
----

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

Encode `datum` as JSON into `result`, using the specified `options`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
static
int
xref:BloombergLP/baljsn/DatumUtil/encode-06.adoc[encode](
    std::pmr::string* result,
    xref:BloombergLP/bdld/Datum.adoc[bdld::Datum] const& datum,
    xref:BloombergLP/baljsn/DatumEncoderOptions.adoc[DatumEncoderOptions] const& options);
----

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

Encode `datum` as JSON into `result` as a `std&colon;&colon;string`, using `options`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
static
int
xref:BloombergLP/baljsn/DatumUtil/encode-0a5.adoc[encode](
    std::string* result,
    xref:BloombergLP/bdld/Datum.adoc[bdld::Datum] const& datum,
    xref:BloombergLP/baljsn/DatumEncoderOptions.adoc[DatumEncoderOptions] const& options);
----

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

== Return Value

0 on success, a negative value on failure, or a positive value if `strictTypes` is enabled and an unsupported type is encoded

== Parameters

[cols="1,4"]
|===
| Name| Description
| *stream*
| output stream for the encoded JSON
| *datum*
| `Datum` to encode
| *result*
| receives the encoded JSON string
| *options*
| encoding options
|===


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