actor-framework
|
Represents an immutable JSON value. More...
#include <json_value.hpp>
Public Member Functions | |
json_value () noexcept | |
Creates a null JSON value. | |
json_value (const detail::json::value *val, detail::json::storage_ptr sptr) noexcept | |
json_value (json_value &&) noexcept=default | |
json_value (const json_value &) noexcept=default | |
json_value & | operator= (json_value &&) noexcept=default |
json_value & | operator= (const json_value &) noexcept=default |
bool | is_null () const noexcept |
Checks whether the value is null . | |
bool | is_undefined () const noexcept |
Checks whether the value is undefined. More... | |
bool | is_integer () const noexcept |
Checks whether the value is an int64_t . | |
bool | is_unsigned () const noexcept |
Checks whether the value is an uint64_t . | |
bool | is_double () const noexcept |
Checks whether the value is a double . | |
bool | is_number () const noexcept |
Checks whether the value is a number, i.e., an int64_t , a uint64_t or a double . More... | |
bool | is_bool () const noexcept |
Checks whether the value is a bool . | |
bool | is_string () const noexcept |
Checks whether the value is a JSON string (std::string_view ). | |
bool | is_array () const noexcept |
Checks whether the value is an JSON array. | |
bool | is_object () const noexcept |
Checks whether the value is a JSON object. | |
int64_t | to_integer (int64_t fallback=0) const |
Converts the value to an int64_t or returns fallback if the value is not a valid number. More... | |
uint64_t | to_unsigned (uint64_t fallback=0) const |
Converts the value to an uint64_t or returns fallback if the value is not a valid number. More... | |
double | to_double (double fallback=0.0) const |
Converts the value to a double or returns fallback if the value is not a valid number. More... | |
bool | to_bool (bool fallback=false) const |
Converts the value to a bool or returns fallback if the value is not a valid boolean. More... | |
std::string_view | to_string () const |
Returns the value as a JSON string or an empty string if the value is not a string. More... | |
std::string_view | to_string (std::string_view fallback) const |
Returns the value as a JSON string or fallback if the value is not a string. More... | |
json_array | to_array () const |
Returns the value as a JSON array or an empty array if the value is not an array. More... | |
json_array | to_array (json_array fallback) const |
Returns the value as a JSON array or fallback if the value is not an array. More... | |
json_object | to_object () const |
Returns the value as a JSON object or an empty object if the value is not an object. More... | |
json_object | to_object (json_object fallback) const |
Returns the value as a JSON object or fallback if the value is not an object. More... | |
bool | equal_to (const json_value &other) const noexcept |
Compares two JSON values for equality. | |
template<class Buffer > | |
void | print_to (Buffer &buf, size_t indentation_factor=0) const |
Prints the JSON value to buf . | |
Static Public Member Functions | |
static json_value | undefined () noexcept |
Creates an undefined JSON value. More... | |
static expected< json_value > | parse (std::string_view str) |
Attempts to parse str as JSON input into a self-contained value. | |
static expected< json_value > | parse_shallow (std::string_view str) |
Attempts to parse str as JSON input into a value that avoids copies where possible by pointing into str . More... | |
static expected< json_value > | parse_in_situ (std::string &str) |
Attempts to parse str as JSON input. More... | |
static expected< json_value > | parse_file (const char *path) |
Attempts to parse the content of the file at path as JSON input into a self-contained value. More... | |
static expected< json_value > | parse_file (const std::string &path) |
Attempts to parse the content of the file at path as JSON input into a self-contained value. More... | |
Friends | |
template<class Inspector > | |
bool | inspect (Inspector &inspector, json_value &val) |
Applies the Inspector to the JSON value val . | |
Related Functions | |
(Note that these are not member functions.) | |
CAF_CORE_EXPORT std::string | to_string (const json_value &val) |
Represents an immutable JSON value.
|
noexcept |
Checks whether the value is a number, i.e., an int64_t
, a uint64_t
or a double
.
|
inlinenoexcept |
Checks whether the value is undefined.
This special state indicates that a previous key lookup failed.
|
static |
Attempts to parse the content of the file at path
as JSON input into a self-contained value.
|
static |
Attempts to parse the content of the file at path
as JSON input into a self-contained value.
|
static |
Attempts to parse str
as JSON input.
Decodes JSON in place and points back into the str
for all strings in the JSON input.
str
. Thus, the input must outlive the json_value and any other JSON objects created from that value.
|
static |
Attempts to parse str
as JSON input into a value that avoids copies where possible by pointing into str
.
str
. Thus, the input must outlive the json_value and any other JSON objects created from that value. json_array caf::json_value::to_array | ( | ) | const |
Returns the value as a JSON array or an empty array if the value is not an array.
json_array caf::json_value::to_array | ( | json_array | fallback | ) | const |
Returns the value as a JSON array or fallback
if the value is not an array.
bool caf::json_value::to_bool | ( | bool | fallback = false | ) | const |
Converts the value to a bool
or returns fallback
if the value is not a valid boolean.
double caf::json_value::to_double | ( | double | fallback = 0.0 | ) | const |
Converts the value to a double
or returns fallback
if the value is not a valid number.
int64_t caf::json_value::to_integer | ( | int64_t | fallback = 0 | ) | const |
Converts the value to an int64_t
or returns fallback
if the value is not a valid number.
json_object caf::json_value::to_object | ( | ) | const |
Returns the value as a JSON object or an empty object if the value is not an object.
json_object caf::json_value::to_object | ( | json_object | fallback | ) | const |
Returns the value as a JSON object or fallback
if the value is not an object.
std::string_view caf::json_value::to_string | ( | ) | const |
Returns the value as a JSON string or an empty string if the value is not a string.
std::string_view caf::json_value::to_string | ( | std::string_view | fallback | ) | const |
Returns the value as a JSON string or fallback
if the value is not a string.
uint64_t caf::json_value::to_unsigned | ( | uint64_t | fallback = 0 | ) | const |
Converts the value to an uint64_t
or returns fallback
if the value is not a valid number.
|
staticnoexcept |
Creates an undefined JSON value.
This special state usually indicates that a previous key lookup failed.
|
related |