A JSONNode wraps a cJSON object and presents useful functions for accessing the different properties of the json structure like operator[]
, isType()
and asType()
methods.
More...
#include <util/u_json.hpp>
|
| JSONNode (cJSON *cjson, bool is_owner, const JSONNode::Ptr &parent) |
| This is public so that make_shared works; do not use outside of this file. More...
|
|
| JSONNode (cJSON *cjson) |
| Wrap cJSON object for easy manipulation, does not take ownership. More...
|
|
| JSONNode () |
| Makes a null object; isInvalid() on it returns true. More...
|
|
| JSONNode (const string &content) |
| Receives a json string and constructs a wrapped cJSON object out of it. More...
|
|
| JSONNode (JSONNode &&)=default |
|
| JSONNode (const JSONNode &node) |
|
JSONNode & | operator= (JSONNode &&)=default |
|
JSONNode & | operator= (JSONNode rhs) |
|
bool | saveToFile (const string &filepath) const |
|
JSONNode | operator[] (const string &key) const |
|
JSONNode | operator[] (int i) const |
|
bool | isObject () const |
|
bool | isArray () const |
|
bool | isString () const |
|
bool | isNumber () const |
|
bool | isInt () const |
|
bool | isDouble () const |
|
bool | isNull () const |
|
bool | isBool () const |
|
bool | isInvalid () const |
|
bool | isValid () const |
|
bool | canBool () const |
|
map< string, JSONNode > | asObject (const map< string, JSONNode > &otherwise=map< string, JSONNode >()) const |
|
vector< JSONNode > | asArray (const vector< JSONNode > &otherwise=vector< JSONNode >()) const |
|
string | asString (const string &otherwise="") const |
|
int | asInt (int otherwise=0) const |
|
double | asDouble (double otherwise=0.0) const |
|
void * | asNull (void *otherwise=nullptr) const |
|
bool | asBool (bool otherwise=false) const |
|
bool | hasKey (const string &key) const |
|
string | toString (bool show_field=true) const |
|
string | getName () const |
|
cJSON * | getCJSON () |
|
|
static JSONNode | loadFromFile (const string &filepath) |
|
A JSONNode wraps a cJSON object and presents useful functions for accessing the different properties of the json structure like operator[]
, isType()
and asType()
methods.
The main ways a user can build a JSONNode is from a json string, from a json file with loadFromFile
or with the JSONBuilder.
◆ JSONNode() [1/4]
xrt::auxiliary::util::json::JSONNode::JSONNode |
( |
cJSON * |
cjson, |
|
|
bool |
is_owner, |
|
|
const JSONNode::Ptr & |
parent |
|
) |
| |
|
inline |
This is public so that make_shared works; do not use outside of this file.
◆ JSONNode() [2/4]
xrt::auxiliary::util::json::JSONNode::JSONNode |
( |
cJSON * |
cjson | ) |
|
|
inline |
Wrap cJSON object for easy manipulation, does not take ownership.
◆ JSONNode() [3/4]
xrt::auxiliary::util::json::JSONNode::JSONNode |
( |
| ) |
|
|
inline |
Makes a null object; isInvalid()
on it returns true.
◆ JSONNode() [4/4]
xrt::auxiliary::util::json::JSONNode::JSONNode |
( |
const string & |
content | ) |
|
|
inline |
Receives a json string and constructs a wrapped cJSON object out of it.
The documentation for this class was generated from the following file: