class::var::JsonObject
class var::JsonObject
: public var::JsonValue
Summary
const JsonObject & value
)
JsonValue at(
const arg::JsonKey key
) const
int clear()
u32 count() const
int insert(
const arg::JsonKey key,
const arg::ImplicitSourceJsonValue value
)
bool is_empty() const
var::Vector< var::String > keys() const
JsonObject & operator=(
const JsonObject & value
)
int remove(
const arg::JsonKey key
)
int update(
const arg::SourceJsonValue value,
enum update_flags o_flags
)
enum update_flags
Members
JsonObject()
JsonObject(
const JsonObject & value
)
JsonValue at(
const arg::JsonKey key
) const
Returns a JsonValue (as a reference) to the specified key.
Parameters
key
The key to access
Returns
A JsonValue (referenced to the key)
If the key does not exist, an invalid JsonValue is returned.
JsonObject json_object;
json_object.insert("name", "john");
json_object.at("name").is_valid(); //this is true
json_object.at("john").is_valid(); //this is false
Becaues the JsonValue is referenced (see JsonValue::is_observer()) the life of the object is not affected when the returned JsonValue is destroyed.
int clear()
Removes all key/value pairs from the object.
Returns
Zero on success
u32 count() const
Returns the number of key/value pairs in the object
Returns
The number of pairs
int insert(
const arg::JsonKey key,
const arg::ImplicitSourceJsonValue value
)
Inserts the key value pair into the object.
Parameters
key
The UTF-8 keyvalue
The value of the key
Returns
Zero on success
If key already exists in the object, it is updated to the new value. If key does not exist in the object, it is created.
bool is_empty() const
Returns true if the object is empty.
var::Vector< var::String > keys() const
JsonObject & operator=(
const JsonObject & value
)
int remove(
const arg::JsonKey key
)
Removes the specified key from the object.
Parameters
key
The key to remove
Returns
Zero on success (-1 is key was not found)
int update(
const arg::SourceJsonValue value,
enum update_flags o_flags
)
enum update_flags
UPDATE_NONE
UPDATE_EXISTING
UPDATE_MISSING
UPDATE_MISSING_AND_EXISTING