|
RADLib
RADical C++ application framework
|
JSON value supporting null, bool, number, string, array, and object. More...
#include <RADCore.h>
Public Member Functions | |
| RADJsonValue () | |
| Creates JSON null. More... | |
| RADJsonValue (std::nullptr_t) | |
| Creates JSON null. More... | |
| RADJsonValue (bool value) | |
| Creates a JSON bool. More... | |
| RADJsonValue (int value) | |
| Creates a JSON number from int. More... | |
| RADJsonValue (int64_t value) | |
| Creates a JSON number from int64. More... | |
| RADJsonValue (double value) | |
| Creates a JSON number from double. More... | |
| RADJsonValue (const char *value) | |
| Creates a JSON string from C string. More... | |
| RADJsonValue (std::string value) | |
| Creates a JSON string. More... | |
| RADJsonValue (const RADJsonValue &other) | |
| Deep-copies arrays and objects so mutations do not alias the source. More... | |
| RADJsonValue (RADJsonValue &&other) noexcept=default | |
| Moves the value without deep-copying. More... | |
| RADJsonValue & | operator= (const RADJsonValue &other) |
| Deep-copies arrays and objects so mutations do not alias the source. More... | |
| RADJsonValue & | operator= (RADJsonValue &&other) noexcept=default |
| Moves the value without deep-copying. More... | |
| JsonType | type () const |
| Returns current JSON type. More... | |
| bool | isNull () const |
| Returns true when value is null. More... | |
| bool | isBool () const |
| Returns true when value is bool. More... | |
| bool | isNumber () const |
| Returns true when value is number. More... | |
| bool | isString () const |
| Returns true when value is string. More... | |
| bool | isArray () const |
| Returns true when value is array. More... | |
| bool | isObject () const |
| Returns true when value is object. More... | |
| bool | toBool (bool defaultValue=false) const |
| Converts to bool or returns defaultValue. More... | |
| double | toNumber (double defaultValue=0.0) const |
| Converts to double or returns defaultValue. More... | |
| int | toInt (int defaultValue=0) const |
| Converts to int or returns defaultValue. More... | |
| int64_t | toInt64 (int64_t defaultValue=0) const |
| Converts to int64 or returns defaultValue. More... | |
| std::string | toString (const std::string &defaultValue={}) const |
| Converts to string or returns defaultValue. More... | |
| size_t | size () const |
| Returns array length or object member count. More... | |
| bool | contains (const std::string &key) const |
| Returns true when object contains key. More... | |
| std::vector< std::string > | keys () const |
| Returns object keys. More... | |
| void | append (RADJsonValue value) |
| Appends value to an array, converting to array if needed. More... | |
| void | remove (const std::string &key) |
| Removes key from an object. More... | |
| RADJsonValue & | operator[] (const std::string &key) |
| Returns object member by key, creating it if needed. More... | |
| const RADJsonValue & | operator[] (const std::string &key) const |
| Returns object member by key or null value when missing. More... | |
| RADJsonValue & | operator[] (size_t index) |
| Returns array element by index, expanding when needed. More... | |
| const RADJsonValue & | operator[] (size_t index) const |
| Returns array element by index or null value when missing. More... | |
| std::string | toJson (bool pretty=false, int indent=0) const |
| Serializes this value to JSON. More... | |
Static Public Member Functions | |
| static RADJsonValue | array () |
| Creates an empty JSON array. More... | |
| static RADJsonValue | object () |
| Creates an empty JSON object. More... | |
JSON value supporting null, bool, number, string, array, and object.
| RADCore::RADJsonValue::RADJsonValue | ( | ) |
Creates JSON null.
| RADCore::RADJsonValue::RADJsonValue | ( | std::nullptr_t | ) |
Creates JSON null.
| RADCore::RADJsonValue::RADJsonValue | ( | bool | value | ) |
Creates a JSON bool.
| RADCore::RADJsonValue::RADJsonValue | ( | int | value | ) |
Creates a JSON number from int.
| RADCore::RADJsonValue::RADJsonValue | ( | int64_t | value | ) |
Creates a JSON number from int64.
| RADCore::RADJsonValue::RADJsonValue | ( | double | value | ) |
Creates a JSON number from double.
| RADCore::RADJsonValue::RADJsonValue | ( | const char * | value | ) |
Creates a JSON string from C string.
| RADCore::RADJsonValue::RADJsonValue | ( | std::string | value | ) |
Creates a JSON string.
| RADCore::RADJsonValue::RADJsonValue | ( | const RADJsonValue & | other | ) |
Deep-copies arrays and objects so mutations do not alias the source.
|
defaultnoexcept |
Moves the value without deep-copying.
| void RADCore::RADJsonValue::append | ( | RADJsonValue | value | ) |
Appends value to an array, converting to array if needed.
|
static |
Creates an empty JSON array.
| bool RADCore::RADJsonValue::contains | ( | const std::string & | key | ) | const |
Returns true when object contains key.
| bool RADCore::RADJsonValue::isArray | ( | ) | const |
Returns true when value is array.
| bool RADCore::RADJsonValue::isBool | ( | ) | const |
Returns true when value is bool.
| bool RADCore::RADJsonValue::isNull | ( | ) | const |
Returns true when value is null.
| bool RADCore::RADJsonValue::isNumber | ( | ) | const |
Returns true when value is number.
| bool RADCore::RADJsonValue::isObject | ( | ) | const |
Returns true when value is object.
| bool RADCore::RADJsonValue::isString | ( | ) | const |
Returns true when value is string.
| std::vector<std::string> RADCore::RADJsonValue::keys | ( | ) | const |
Returns object keys.
|
static |
Creates an empty JSON object.
| RADJsonValue& RADCore::RADJsonValue::operator= | ( | const RADJsonValue & | other | ) |
Deep-copies arrays and objects so mutations do not alias the source.
|
defaultnoexcept |
Moves the value without deep-copying.
| RADJsonValue& RADCore::RADJsonValue::operator[] | ( | const std::string & | key | ) |
Returns object member by key, creating it if needed.
| const RADJsonValue& RADCore::RADJsonValue::operator[] | ( | const std::string & | key | ) | const |
Returns object member by key or null value when missing.
| RADJsonValue& RADCore::RADJsonValue::operator[] | ( | size_t | index | ) |
Returns array element by index, expanding when needed.
| const RADJsonValue& RADCore::RADJsonValue::operator[] | ( | size_t | index | ) | const |
Returns array element by index or null value when missing.
| void RADCore::RADJsonValue::remove | ( | const std::string & | key | ) |
Removes key from an object.
| size_t RADCore::RADJsonValue::size | ( | ) | const |
Returns array length or object member count.
| bool RADCore::RADJsonValue::toBool | ( | bool | defaultValue = false | ) | const |
Converts to bool or returns defaultValue.
| int RADCore::RADJsonValue::toInt | ( | int | defaultValue = 0 | ) | const |
Converts to int or returns defaultValue.
| int64_t RADCore::RADJsonValue::toInt64 | ( | int64_t | defaultValue = 0 | ) | const |
Converts to int64 or returns defaultValue.
| std::string RADCore::RADJsonValue::toJson | ( | bool | pretty = false, |
| int | indent = 0 |
||
| ) | const |
Serializes this value to JSON.
| double RADCore::RADJsonValue::toNumber | ( | double | defaultValue = 0.0 | ) | const |
Converts to double or returns defaultValue.
| std::string RADCore::RADJsonValue::toString | ( | const std::string & | defaultValue = {} | ) | const |
Converts to string or returns defaultValue.
| JsonType RADCore::RADJsonValue::type | ( | ) | const |
Returns current JSON type.