#include <Json.h>
Classes | |
| class | ExcChildNotFound |
| Exception expressing the absence of an expected child node. More... | |
| class | Exception |
| class | ExcJsonParserError |
| Exception expressing the existence of errors when serializing or deserializing JSON. More... | |
| class | ExcNonConvertible |
| Exception expressing the inability to convert a node's value to a requested type. More... | |
| class | ParseOptions |
| class | WriteOptions |
Options for JSON writing. Passed to the write method. More... | |
Public Member Functions | |
| JsonTree () | |
| Creates a null JsonTree. | |
| JsonTree (const JsonTree &jsonTree) | |
| Parses the JSON contained in the string xmlString. | |
| JsonTree (DataSourceRef dataSource, ParseOptions parseOptions=ParseOptions()) | |
Parses JSON contained in dataSource. Commonly used with the results of loadUrl(), loadFile() or loadResource(). JsonTree myDoc( loadUrl( "http://search.twitter.com/search.json?q=libcinder&rpp=10&result_type=recent" ) ); | |
| JsonTree (const std::string &jsonString, ParseOptions parseOptions=ParseOptions()) | |
| Parses the JSON contained in the string jsonString . | |
| JsonTree (const std::string &key, bool value) | |
| Creates a JsonTree with key key and boolean value . | |
| JsonTree (const std::string &key, double value) | |
| Creates a JsonTree with key key and double value . | |
| JsonTree (const std::string &key, float value) | |
| Creates a JsonTree with key key and double value cast from float. | |
| JsonTree (const std::string &key, int value) | |
| Creates a JsonTree with key key and int value . | |
| JsonTree (const std::string &key, const std::string &value) | |
| Creates a JsonTree with key key and string value . | |
| JsonTree (const std::string &key, const char *value) | |
| Creates a JsonTree with key key and string value cast from const char*. | |
| JsonTree (const std::string &key, uint32_t value) | |
| Creates a JsonTree with key key and uint32_t value . | |
| JsonTree (const std::string &key, int64_t value) | |
| Creates a JsonTree with key key and int64_t value . | |
| JsonTree (const std::string &key, uint64_t value) | |
| Creates a JsonTree with key key and uint64_t value . | |
| std::string | serialize () const |
| Returns the JsonTree as a string with standard formatting. | |
| Iter | begin () |
| Returns an Iter to the first child of this node. | |
| ConstIter | begin () const |
| Returns a ConstIter to the first child of this node. | |
| Iter | end () |
| Returns an Iter which marks the end of the children of this node. | |
| ConstIter | end () const |
| Returns a ConstIter which marks the end of the children of this node. | |
| JsonTree & | operator= (const JsonTree &jsonTree) |
| Assigns the JsonTree a new value, and creates it if it doesn't exist. | |
| JsonTree & | operator[] (const std::string &relativePath) |
| const JsonTree & | operator[] (const std::string &relativePath) const |
| JsonTree & | operator[] (size_t index) |
| Returns the child at index. Throws ExcChildNotFound if none matches. | |
| const JsonTree & | operator[] (size_t index) const |
| Returns the child at index. Throws ExcChildNotFound if none matches. | |
| JsonTree & | getChild (const std::string &relativePath, bool caseSensitive=false, char separator= '.') |
| const JsonTree & | getChild (const std::string &relativePath, bool caseSensitive=false, char separator= '.') const |
| JsonTree & | getChild (size_t index) |
| Returns the child at index. Throws ExcChildNotFound if none matches. | |
| const JsonTree & | getChild (size_t index) const |
| Returns the child at index. Throws ExcChildNotFound if none matches. | |
| const Container & | getChildren () const |
| Returns a reference to the node's list of children nodes. | |
| bool | hasChild (const std::string &relativePath, bool caseSensitive=false, char separator= '.') const |
| bool | hasChildren () const |
| Returns whether this node has a parent node. | |
| JsonTree & | getParent () |
| Returns a reference to the node which is the parent of this node. | |
| const JsonTree & | getParent () const |
| Returns a reference to the node which is the parent of this node. | |
| bool | hasParent () const |
| Returns whether this node has a parent node. | |
| void | clear () |
| Removes all child nodes. | |
| void | pushBack (const JsonTree &newChild) |
| void | removeChild (size_t index) |
| Removes the child at index. Throws ExcChildNotFound if none matches. | |
| Iter | removeChild (Iter pos) |
| Removes the child at pos. Throws ExcChildNotFound if none matches. | |
| void | replaceChild (size_t index, const JsonTree &newChild) |
| Repalces the child at index with JsonTree newChild. Throws ExcChildNotFound if none matches. | |
| void | replaceChild (Iter pos, const JsonTree &newChild) |
| Repalces the child at pos with JsonTree newChild. Throws ExcChildNotFound if none matches. | |
| void | write (const fs::path &path, WriteOptions writeOptions=WriteOptions()) |
| void | write (DataTargetRef target, WriteOptions writeOptions=WriteOptions()) |
| const std::string & | getKey () const |
| Returns the node's key as a string. Returns index if node does not have a key. | |
| std::string | getPath (char separator= '.') const |
| template<typename T > | |
| T | getValue () const |
Returns the value of the node cast to T using ci::fromString(). float value = myNode.getValue<float>( "key" ); | |
| const std::string & | getValue () const |
| Returns the value of the node. | |
Static Public Member Functions | |
| static JsonTree | makeArray (const std::string &key="") |
| static JsonTree | makeObject (const std::string &key="") |
Friends | |
| std::ostream & | operator<< (std::ostream &out, const JsonTree &json) |
| Streams the JsonTree json to std::ostream out with standard formatting. | |
| cinder::JsonTree::JsonTree | ( | ) | [explicit] |
Creates a null JsonTree.
| cinder::JsonTree::JsonTree | ( | const JsonTree & | jsonTree | ) |
Parses the JSON contained in the string xmlString.
| cinder::JsonTree::JsonTree | ( | DataSourceRef | dataSource, |
| ParseOptions | parseOptions = ParseOptions() |
||
| ) | [explicit] |
Parses JSON contained in dataSource. Commonly used with the results of loadUrl(), loadFile() or loadResource().
JsonTree myDoc( loadUrl( "http://search.twitter.com/search.json?q=libcinder&rpp=10&result_type=recent" ) );
| cinder::JsonTree::JsonTree | ( | const std::string & | jsonString, |
| ParseOptions | parseOptions = ParseOptions() |
||
| ) | [explicit] |
Parses the JSON contained in the string jsonString .
| cinder::JsonTree::JsonTree | ( | const std::string & | key, |
| bool | value | ||
| ) | [explicit] |
Creates a JsonTree with key key and boolean value .
| cinder::JsonTree::JsonTree | ( | const std::string & | key, |
| double | value | ||
| ) | [explicit] |
Creates a JsonTree with key key and double value .
| cinder::JsonTree::JsonTree | ( | const std::string & | key, |
| float | value | ||
| ) | [explicit] |
Creates a JsonTree with key key and double value cast from float.
| cinder::JsonTree::JsonTree | ( | const std::string & | key, |
| int | value | ||
| ) | [explicit] |
Creates a JsonTree with key key and int value .
| cinder::JsonTree::JsonTree | ( | const std::string & | key, |
| const std::string & | value | ||
| ) | [explicit] |
Creates a JsonTree with key key and string value .
| cinder::JsonTree::JsonTree | ( | const std::string & | key, |
| const char * | value | ||
| ) | [explicit] |
Creates a JsonTree with key key and string value cast from const char*.
| cinder::JsonTree::JsonTree | ( | const std::string & | key, |
| uint32_t | value | ||
| ) | [explicit] |
Creates a JsonTree with key key and uint32_t value .
| cinder::JsonTree::JsonTree | ( | const std::string & | key, |
| int64_t | value | ||
| ) | [explicit] |
Creates a JsonTree with key key and int64_t value .
| cinder::JsonTree::JsonTree | ( | const std::string & | key, |
| uint64_t | value | ||
| ) | [explicit] |
Creates a JsonTree with key key and uint64_t value .
| JsonTree cinder::JsonTree::makeArray | ( | const std::string & | key = "" | ) | [static] |
! Creates a JsonTree with key key and an empty array.
| JsonTree cinder::JsonTree::makeObject | ( | const std::string & | key = "" | ) | [static] |
! Creates a JsonTree with key key as an empty object.
| string cinder::JsonTree::serialize | ( | ) | const |
Returns the JsonTree as a string with standard formatting.
| JsonTree::Iter cinder::JsonTree::begin | ( | ) |
Returns an Iter to the first child of this node.
| JsonTree::ConstIter cinder::JsonTree::begin | ( | ) | const |
Returns a ConstIter to the first child of this node.
| JsonTree::Iter cinder::JsonTree::end | ( | ) |
Returns an Iter which marks the end of the children of this node.
| JsonTree::ConstIter cinder::JsonTree::end | ( | ) | const |
Returns a ConstIter which marks the end of the children of this node.
Assigns the JsonTree a new value, and creates it if it doesn't exist.
| JsonTree & cinder::JsonTree::operator[] | ( | const std::string & | relativePath | ) |
! Returns the child at relativePath. Throws ExcChildNotFound if none matches.
JsonTree node = myNode[ "path.to.child" ];
| const JsonTree & cinder::JsonTree::operator[] | ( | const std::string & | relativePath | ) | const |
! Returns the child at relativePath. Throws ExcChildNotFound if none matches.
JsonTree node = myNode[ "path.to.child" ];
| JsonTree & cinder::JsonTree::operator[] | ( | size_t | index | ) |
Returns the child at index. Throws ExcChildNotFound if none matches.
| const JsonTree & cinder::JsonTree::operator[] | ( | size_t | index | ) | const |
Returns the child at index. Throws ExcChildNotFound if none matches.
| JsonTree & cinder::JsonTree::getChild | ( | const std::string & | relativePath, |
| bool | caseSensitive = false, |
||
| char | separator = '.' |
||
| ) |
! Returns the child at relativePath. Throws ExcChildNotFound if none matches.
JsonTree node = myNode.getChild( "path.to.child" );
| const JsonTree & cinder::JsonTree::getChild | ( | const std::string & | relativePath, |
| bool | caseSensitive = false, |
||
| char | separator = '.' |
||
| ) | const |
! Returns the child at relativePath. Throws ExcChildNotFound if none matches.
JsonTree node = myNode.getChild( "path.to.child" );
| JsonTree & cinder::JsonTree::getChild | ( | size_t | index | ) |
Returns the child at index. Throws ExcChildNotFound if none matches.
| const JsonTree & cinder::JsonTree::getChild | ( | size_t | index | ) | const |
Returns the child at index. Throws ExcChildNotFound if none matches.
| const JsonTree::Container & cinder::JsonTree::getChildren | ( | ) | const |
Returns a reference to the node's list of children nodes.
| bool cinder::JsonTree::hasChild | ( | const std::string & | relativePath, |
| bool | caseSensitive = false, |
||
| char | separator = '.' |
||
| ) | const |
! Returns whether the child at relativePath exists.
bool nodeExists = myNode.hasChild( "path.to.child" );
| bool cinder::JsonTree::hasChildren | ( | ) | const |
Returns whether this node has a parent node.
Returns a reference to the node which is the parent of this node.
| const JsonTree & cinder::JsonTree::getParent | ( | ) | const |
Returns a reference to the node which is the parent of this node.
| bool cinder::JsonTree::hasParent | ( | ) | const |
Returns whether this node has a parent node.
| void cinder::JsonTree::clear | ( | ) |
Removes all child nodes.
| void cinder::JsonTree::pushBack | ( | const JsonTree & | newChild | ) |
! Appends a copy of the node newChild to the children of this node. If this is a value node, it will change to an object or an array. If newChild has a key, this becomes an object node. If not, this becomes an array node.
| void cinder::JsonTree::removeChild | ( | size_t | index | ) |
Removes the child at index. Throws ExcChildNotFound if none matches.
| Iter cinder::JsonTree::removeChild | ( | Iter | pos | ) |
Removes the child at pos. Throws ExcChildNotFound if none matches.
| void cinder::JsonTree::replaceChild | ( | size_t | index, |
| const JsonTree & | newChild | ||
| ) |
Repalces the child at index with JsonTree newChild. Throws ExcChildNotFound if none matches.
| void cinder::JsonTree::replaceChild | ( | Iter | pos, |
| const JsonTree & | newChild | ||
| ) |
Repalces the child at pos with JsonTree newChild. Throws ExcChildNotFound if none matches.
| void cinder::JsonTree::write | ( | const fs::path & | path, |
| JsonTree::WriteOptions | writeOptions = WriteOptions() |
||
| ) |
! Writes this JsonTree to path with standard formatting. If writeOptions creates a document then an implicit parent object node is created when necessary and this is treated as the root element. If writeOptions indents then the JSON string will be indented.
| void cinder::JsonTree::write | ( | DataTargetRef | target, |
| JsonTree::WriteOptions | writeOptions = WriteOptions() |
||
| ) |
! Writes this JsonTree to target. If writeOptions creates a document then an implicit parent object node is created when necessary and this is treated as the root element. If writeOptions indents then the JSON string will be indented.
| const string & cinder::JsonTree::getKey | ( | ) | const |
Returns the node's key as a string. Returns index if node does not have a key.
| string cinder::JsonTree::getPath | ( | char | separator = '.' | ) | const |
! Returns a path to this node, separated by the character separator.
| T cinder::JsonTree::getValue | ( | ) | const |
Returns the value of the node cast to T using ci::fromString().
float value = myNode.getValue<float>( "key" );
!
| const std::string& cinder::JsonTree::getValue | ( | ) | const |
Returns the value of the node.
| std::ostream& operator<< | ( | std::ostream & | out, |
| const JsonTree & | json | ||
| ) | [friend] |
Streams the JsonTree json to std::ostream out with standard formatting.