[#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 `<baljsn_datumutil.h>` Encode the specified `datum` as a JSON string, and write it into the specified `stream`. Return 0 on success, and a negative value if `datum` could not be encoded (which may leave a partial JSON sequence on the `stream`). If the optionally specified `options` argument is not present, treat it as a default‐constructed `DatumEncoderOptions`. If `options.strictTypes` is `true` and a type that is not supported by JSON, or a singular double value (e.g., NaN or infinity) is being encoded (see []Types)) return a positive value, but also populate `result` with an encoded JSON string (i.e., the value of `result` is the same regardless of the `strictTypes` option, but if `strictTypes` is `true` a non‐zero positive status will be returned). The mapping of types supported by `Datum` to JSON types is described in []Types). [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..._]# Encode the specified `datum` as a JSON string, and load the specified `result` with the encoded JSON string. Return 0 on success, and a negative value if `datum` could not be encoded (with no effect on `result`). If the optionally specified `options` argument is not present, treat it as a default‐constructed `DatumEncoderOptions`. If `options.strictTypes` is `true` and a type that is not supported by JSON, or a singular double value (e.g., NaN or infinity) is being encoded (see []Types)) return a positive value, but also populate `result` with an encoded JSON string (i.e., the value of `result` is the same regardless of the `strictTypes` option, but if `strictTypes` is `true` a non‐zero positive status will be returned). The mapping of types supported by `Datum` to JSON types is described in []Types). [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..._]# Same as the preceding overload, loading into a `std::pmr::string`. [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..._]# Same as the preceding overload, loading into a `std::string`. [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..._]# Same as the preceding overload, using the specified `options`. [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..._]# Same as the preceding overload, using the specified `options`. [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..._]# Same as the preceding overload, loading into a `std::pmr::string`. [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..._]# Same as the preceding overload, loading into a `std::string`. [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..._]# [.small]#Created with https://www.mrdocs.com[MrDocs]#