[#BloombergLP-baljsn-Encoder-encode-09] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/baljsn.adoc[baljsn]::xref:BloombergLP/baljsn/Encoder.adoc[Encoder]::encode :relfileprefix: ../../../ :mrdocs: Encode `value` as JSON onto `stream` using `options`. == Synopsis Declared in `<baljsn_encoder.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class TYPE> int encode( std::ostream& stream, TYPE const& value, xref:BloombergLP/baljsn/EncoderOptions.adoc[EncoderOptions] const& options); ---- == Description Encode the specified `value`, of (template parameter) `TYPE`, in the JSON format using the specified `options` and output it onto the specified `stream`. Specifying a nullptr `options` is equivalent to passing a default‐constructed EncoderOptions in `options`. `TYPE` shall be a `bdlat`‐compatible choice, or array type, or a `bdlat`‐compatible dynamic type referring to one of those types. == Return Value 0 on success, and a non‐zero value otherwise == Parameters [cols="1,4"] |=== | Name| Description | *stream* | output stream for JSON | *value* | value to encode | *options* | encoding options |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#