JSON Voorhees
Killer JSON for C++
|
An encoder that outputs to an std::ostream
.
More...
#include <jsonv/encode.hpp>
Public Member Functions | |
ostream_encoder (std::ostream &output) | |
Create an instance which places text into output. More... | |
void | ensure_ascii (bool value) |
If set to true (the default), then all non-ASCII characters in strings will be replaced with their numeric encodings. More... | |
Public Member Functions inherited from jsonv::encoder | |
void | encode (const jsonv::value &source) |
Encode some source value into this encoder. More... | |
Protected Member Functions | |
virtual void | write_null () override |
Write the null value. More... | |
virtual void | write_object_begin () override |
Write the opening of an object value. More... | |
virtual void | write_object_end () override |
Write the closing of an object value. More... | |
virtual void | write_object_key (string_view key) override |
Write the key for an object, including the separator. More... | |
virtual void | write_object_delimiter () override |
Write the delimiter between two entries in an object. More... | |
virtual void | write_array_begin () override |
Write the opening of an array value. More... | |
virtual void | write_array_end () override |
Write the closing of an array value. More... | |
virtual void | write_array_delimiter () override |
Write the delimiter between two entries in an array. More... | |
virtual void | write_string (string_view value) override |
Write a string value. More... | |
virtual void | write_integer (std::int64_t value) override |
Write an integer value. More... | |
virtual void | write_decimal (double value) override |
When a special value is given, this will output null . More... | |
virtual void | write_boolean (bool value) override |
Write a boolean value. More... | |
std::ostream & | output () |
An encoder that outputs to an std::ostream
.
This implementation is used for operator<<
on a value
.
Definition at line 141 of file encode.hpp.
|
explicit |
Create an instance which places text into output.
void jsonv::ostream_encoder::ensure_ascii | ( | bool | value | ) |
If set to true (the default), then all non-ASCII characters in strings will be replaced with their numeric encodings.
Since JSON allows for encoded text to be contained in a document, this is inefficient if you have many non-ASCII characters. If you know that your decoding side can properly handle UTF-8 encoding, then you should turn this on.
|
overrideprotectedvirtual |
Write the opening of an array value.
Implements jsonv::encoder.
Reimplemented in jsonv::ostream_pretty_encoder.
|
overrideprotectedvirtual |
Write the delimiter between two entries in an array.
Implements jsonv::encoder.
Reimplemented in jsonv::ostream_pretty_encoder.
|
overrideprotectedvirtual |
Write the closing of an array value.
Implements jsonv::encoder.
Reimplemented in jsonv::ostream_pretty_encoder.
|
overrideprotectedvirtual |
Write a boolean value.
Implements jsonv::encoder.
Reimplemented in jsonv::ostream_pretty_encoder.
|
overrideprotectedvirtual |
When a special value is given, this will output null
.
Implements jsonv::encoder.
Reimplemented in jsonv::ostream_pretty_encoder.
|
overrideprotectedvirtual |
Write an integer value.
Implements jsonv::encoder.
Reimplemented in jsonv::ostream_pretty_encoder.
|
overrideprotectedvirtual |
|
overrideprotectedvirtual |
Write the opening of an object value.
Implements jsonv::encoder.
Reimplemented in jsonv::ostream_pretty_encoder.
|
overrideprotectedvirtual |
Write the delimiter between two entries in an object.
Implements jsonv::encoder.
Reimplemented in jsonv::ostream_pretty_encoder.
|
overrideprotectedvirtual |
Write the closing of an object value.
Implements jsonv::encoder.
Reimplemented in jsonv::ostream_pretty_encoder.
|
overrideprotectedvirtual |
Write the key for an object, including the separator.
Implements jsonv::encoder.
Reimplemented in jsonv::ostream_pretty_encoder.
|
overrideprotectedvirtual |
Write a string value.
value | is the string to write. It will hopefully be encoded as valid UTF-8. It is the implementation's choice of how to deal with malformed string values. Two common options are to replace malformed sequences with ?s or to simply output these encodings and let the receiver deal with them. |
Implements jsonv::encoder.
Reimplemented in jsonv::ostream_pretty_encoder.