25 using Array = std::vector<JsonValue>;
26 using Object = std::vector<std::pair<std::string, JsonValue>>;
47 [[nodiscard]]
Type type()
const {
return type_; }
One JSON value: null, a boolean, a number, a string, an array or an object.
Definition json.hpp:22
Type type() const
Definition json.hpp:47
const Object & as_object() const
const Array & as_array() const
const JsonValue * find(std::string_view key) const
The member named key of an object, or nullptr if there is none.
static JsonValue Float(float f)
A number written with the shortest text that reads back as the same float.
JsonValue(double d)
A number written with the shortest text that reads back as the same double.
const std::string & as_string() const
void push_back(JsonValue value)
Appends an element to an array.
friend JsonValue ParseJson(std::string_view text)
Parses one JSON document.
const std::string & number_text() const
A number's text exactly as written or parsed, for example "0.1".
JsonValue(const char *s)
Definition json.hpp:39
std::vector< JsonValue > Array
Definition json.hpp:25
std::vector< std::pair< std::string, JsonValue > > Object
Definition json.hpp:26
JsonValue(std::nullptr_t)
A null.
Definition json.hpp:31
void add(std::string key, JsonValue value)
Appends a member to an object. Keys must be unique.
friend class JsonParser
Definition json.hpp:84
Type
Definition json.hpp:24
JsonValue(int i)
Definition json.hpp:37
bool is_null() const
Definition json.hpp:48
JsonValue()=default
A null.
Definition acquisition_functions.hpp:16
JsonValue ParseJson(std::string_view text)
Parses one JSON document.
std::string WriteJson(const JsonValue &value)
Writes value as JSON, indented by two spaces and ending with a newline.
std::string WriteJsonCompact(const JsonValue &value)
Writes value as JSON on one line, with no whitespace and no trailing newline.