Open Lighting Architecture  0.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | List of all members
ola::web::JsonObject Class Reference

Detailed Description

A JSON object. JSON Objects are key : value mappings, similar to dictionaries in Python.

If the same key is added more than once, the latest value wins.

Todo:
Since key names tend to reuse the same strings, it would be nice to intern the strings here. That's a future optimization for someone.
Inheritance diagram for ola::web::JsonObject:
ola::web::JsonValue

Public Member Functions

 JsonObject ()
 Create a new JsonObject.
void Add (const std::string &key, const std::string &value)
 Add a key to string mapping.
void Add (const std::string &key, const char *value)
 Set the given key to a string value.
void Add (const std::string &key, unsigned int i)
 Set the given key to a unsigned int value.
void Add (const std::string &key, int i)
 Set the given key to a int value.
void Add (const std::string &key, bool value)
 Set the given key to a bool value.
void Add (const std::string &key)
 Set the given key to a null value.
JsonObjectAddObject (const std::string &key)
 Set the given key to a JsonObject.
class JsonArrayAddArray (const std::string &key)
 Set the given key to a JsonArray.
void AddRaw (const std::string &key, const std::string &value)
 Set the given key to a raw value.
void ToString (std::ostream *output, unsigned int indent) const
 Output the string representation of this value to an ostream.

Additional Inherited Members

- Protected Member Functions inherited from ola::web::JsonValue
void Indent (std::ostream *output, unsigned int indent) const
 Append the give number of spaces to the output stream.
- Static Protected Attributes inherited from ola::web::JsonValue
static const unsigned int DEFAULT_INDENT = 2
 the default indent level

Member Function Documentation

void ola::web::JsonObject::Add ( const std::string &  key,
const std::string &  value 
)

Add a key to string mapping.

Parameters
keythe key to set.
valuethe value to add.
void ola::web::JsonObject::Add ( const std::string &  key,
const char *  value 
)

Set the given key to a string value.

Parameters
keythe key to set.
valuethe value to add
void ola::web::JsonObject::Add ( const std::string &  key,
unsigned int  i 
)

Set the given key to a unsigned int value.

Parameters
keythe key to set.
ithe value to add
void ola::web::JsonObject::Add ( const std::string &  key,
int  i 
)

Set the given key to a int value.

Parameters
keythe key to set.
ithe value to add
void ola::web::JsonObject::Add ( const std::string &  key,
bool  value 
)

Set the given key to a bool value.

Parameters
keythe key to set.
valuethe value to add
void ola::web::JsonObject::Add ( const std::string &  key)

Set the given key to a null value.

Parameters
keythe key to set.
JsonArray * ola::web::JsonObject::AddArray ( const std::string &  key)

Set the given key to a JsonArray.

Parameters
keythe key to add
Returns
the new JsonObject.
JsonObject * ola::web::JsonObject::AddObject ( const std::string &  key)

Set the given key to a JsonObject.

Parameters
keythe key to add
Returns
the new JsonObject.
void ola::web::JsonObject::AddRaw ( const std::string &  key,
const std::string &  value 
)

Set the given key to a raw value.

Parameters
keythe key to add
valuethe raw value to append.
void ola::web::JsonObject::ToString ( std::ostream *  output,
unsigned int  indent 
) const
virtual

Output the string representation of this value to an ostream.

Parameters
outputthe ostream to output to.
indentthe number of spaces to prepend.

Implements ola::web::JsonValue.


The documentation for this class was generated from the following files: