66 json_writer & begin_object(
bool const inline_elements =
false);
68 json_writer & begin_array(
bool const inline_elements =
false);
75 template <std::
unsigned_
integral number_t>
78 return write_unsigned(
static_cast<uint64_t
>(value));
82 template <std::
floating_po
int number_t>
85 return write_double(
static_cast<double>(value));
93 bool inline_elements{};
106 void open(
bool const is_object,
bool const inline_elements);
107 void close(
bool const is_object);
108 void indent(
size_t const level);
109 json_writer & write_unsigned(uint64_t
const value);
Writes JSON to a stream, indented by two spaces.
Definition json_writer.hpp:51
void write_separator(container &parent)
Writes the comma and line break or space that precede an element of parent.
Definition json_writer.cpp:183
json_writer & key(std::string_view const name)
Names the next value. Only valid inside an object.
Definition json_writer.cpp:83
bool has_key
Whether raptor::json_writer::key has been called for the next value.
Definition json_writer.hpp:100
void prepare_value()
Writes what has to precede a value: a separator and indentation, or nothing after a key.
Definition json_writer.cpp:162
json_writer & number(number_t const value)
Writes null if value is not finite.
Definition json_writer.hpp:83
std::string json_quote(std::string_view const value)
Returns value as a JSON string literal, including the enclosing quotes.
Definition json_writer.cpp:22
std::string shortest_double(double const value)
Returns the shortest representation of value that reads back as the same double.
Definition json_writer.cpp:74
The state of an open container.
Definition json_writer.hpp:91