Class representing a JSON value. More...
#include <json_value.h>
Public Types | |
enum | Type { Type::undefined, Type::null, Type::object, Type::array, Type::string, Type::number, Type::boolean } |
value type More... | |
Public Member Functions | |
Attributes | |
operator bool () const | |
Convert value to a different type. More... | |
operator std::string () const | |
operator float () const | |
operator double () const | |
operator int () const | |
JsonValue & | operator[] (const char *key) |
Indexers for object members or array items. More... | |
JsonValue & | operator[] (const std::string &key) |
const JsonValue & | operator[] (const char *key) const |
const JsonValue & | operator[] (const std::string &key) const |
const JsonValue & | operator[] (int index) const |
JsonValue & | operator[] (int index) |
Type | get_type () const |
Get value type. More... | |
size_t | get_size () const |
Get size of value. More... | |
std::map< std::string, JsonValue > & | get_members () |
Get object members. More... | |
const std::map< std::string, JsonValue > & | get_members () const |
std::vector< JsonValue > & | get_items () |
Get array items. More... | |
const std::vector< JsonValue > & | get_items () const |
bool | is_undefined () const |
Return true if value is undefined. More... | |
bool | is_null () const |
Return true if value is null. More... | |
bool | is_object () const |
Return true if value is an object. More... | |
bool | is_array () const |
Return true if value is an array. More... | |
bool | is_string () const |
Return true if value is a string. More... | |
bool | is_number () const |
Return true if value is a number. More... | |
bool | is_boolean () const |
Return true if value is a boolean. More... | |
std::string | to_string () const |
Convert value object to a string. More... | |
int | to_int () const |
Convert value object to an int. More... | |
float | to_float () const |
Convert value object to a float. More... | |
double | to_double () const |
Convert value object to a double. More... | |
bool | to_boolean () const |
Convert value object to a boolean. More... | |
Operations | |
template<typename T > | |
JsonValue & | operator= (const T &value) |
Assign a new value. More... | |
JsonValue & | operator= (const JsonValue &value) |
template<typename Type > | |
std::map< std::string, Type > | to_map () const |
Convert value object to a std::map with the template specified value type. More... | |
template<typename Type > | |
std::vector< Type > | to_vector () const |
Convert value array to a std::vector with the template specified value type. More... | |
std::string | to_json () const |
Create an UTF-8 JSON string for the value. More... | |
void | to_json (std::string &result) const |
Construction | |
static JsonValue | object () |
Create a object value. More... | |
static JsonValue | array () |
Create a array value. More... | |
static JsonValue | null () |
Create a null value. More... | |
static JsonValue | string (const std::string &value) |
Create a string value. More... | |
static JsonValue | boolean (bool value) |
Create a boolean value. More... | |
static JsonValue | number (int value) |
Create a number value. More... | |
static JsonValue | number (double value) |
static JsonValue | from_json (const std::string &json) |
Create a value from UTF-8 JSON string. More... | |
JsonValue () | |
Constructs a value. More... | |
JsonValue (Type type) | |
JsonValue (bool value) | |
JsonValue (int value) | |
JsonValue (double value) | |
JsonValue (const char *value) | |
JsonValue (const std::string &value) | |
Class representing a JSON value.
|
strong |
|
inline |
Constructs a value.
References clan::undefined.
Referenced by array(), boolean(), null(), number(), object(), operator=(), and string().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinestatic |
Create a array value.
References array, and JsonValue().
|
inlinestatic |
Create a boolean value.
References JsonValue().
|
static |
Create a value from UTF-8 JSON string.
|
inline |
Get array items.
|
inline |
|
inline |
Get object members.
|
inline |
|
inline |
|
inline |
Get value type.
|
inline |
Return true if value is an array.
References array.
|
inline |
Return true if value is a boolean.
References boolean.
|
inline |
Return true if value is null.
References null.
|
inline |
Return true if value is a number.
References number.
|
inline |
Return true if value is an object.
References object.
|
inline |
Return true if value is a string.
References string.
|
inline |
Return true if value is undefined.
References undefined.
|
inlinestatic |
Create a null value.
References JsonValue(), and null.
|
inlinestatic |
References JsonValue().
|
inlinestatic |
Create a number value.
References JsonValue().
|
inlinestatic |
|
inlineexplicit |
Convert value to a different type.
References to_boolean().
|
inline |
References to_double().
|
inline |
References to_float().
|
inline |
References to_int().
|
inline |
References to_string().
|
inline |
Assign a new value.
References JsonValue().
|
inline |
Indexers for object members or array items.
|
inline |
References clan::undefined.
|
inline |
|
inline |
References clan::undefined.
|
inline |
|
inline |
|
inlinestatic |
Create a string value.
References JsonValue().
|
inline |
|
inline |
|
inline |
|
inline |
std::string clan::JsonValue::to_json | ( | ) | const |
Create an UTF-8 JSON string for the value.
void clan::JsonValue::to_json | ( | std::string & | result | ) | const |
|
inline |
Convert value object to a std::map with the template specified value type.
References object.
|
inline |
|
inline |
Convert value array to a std::vector with the template specified value type.
References array.