CUGL
Cornell University Game Library
CUJsonValue.h
1 //
2 // CUJsonValue.h
3 // Cornell University Game Library (CUGL)
4 //
5 // This module a modern C++ alternative to the cJSON interface for reading
6 // JSON files. In particular, this gives us better type-checking and memory
7 // management. With that said, it still uses cJSON as the underlying parsing
8 // engine.
9 //
10 // This class uses our standard shared-pointer architecture.
11 //
12 // 1. The constructor does not perform any initialization; it just sets all
13 // attributes to their defaults.
14 //
15 // 2. All initialization takes place via init methods, which can fail if an
16 // object is initialized more than once.
17 //
18 // 3. All allocation takes place via static constructors which return a shared
19 // pointer.
20 //
21 //
22 // CUGL zlib License:
23 // This software is provided 'as-is', without any express or implied
24 // warranty. In no event will the authors be held liable for any damages
25 // arising from the use of this software.
26 //
27 // Permission is granted to anyone to use this software for any purpose,
28 // including commercial applications, and to alter it and redistribute it
29 // freely, subject to the following restrictions:
30 //
31 // 1. The origin of this software must not be misrepresented; you must not
32 // claim that you wrote the original software. If you use this software
33 // in a product, an acknowledgment in the product documentation would be
34 // appreciated but is not required.
35 //
36 // 2. Altered source versions must be plainly marked as such, and must not
37 // be misrepresented as being the original software.
38 //
39 // 3. This notice may not be removed or altered from any source distribution.
40 //
41 // Author: Walker White
42 // Version: 11/28/16
43 //
44 #ifndef __CU_JSON_VALUE_H__
45 #define __CU_JSON_VALUE_H__
46 #include <cJSON/cJSON.h>
47 #include <vector>
48 #include <string>
49 
50 namespace cugl {
51 
68 class JsonValue {
69 public:
77  enum class Type : int {
79  NullType = 0,
81  BoolType = 1,
83  NumberType = 2,
85  StringType = 3,
87  ArrayType = 4,
89  ObjectType = 5
90  };
91 
92 private:
94  Type _type;
95 
97  JsonValue* _parent;
99  std::string _key;
100 
102  std::string _stringValue;
104  long _longValue;
106  double _doubleValue;
107 
109  std::vector<std::shared_ptr<JsonValue>> _children;
110 
111 #pragma mark -
112 #pragma mark cJSON Conversions
113 
126  static std::shared_ptr<JsonValue> toJsonValue(const cJSON* node);
127 
139  static void toJsonValue(JsonValue* value, const cJSON* node);
140 
152  static cJSON* toCJSON(const JsonValue* value);
153 
154 #pragma mark -
155 #pragma mark Constructors
156 public:
163  JsonValue();
164 
171  ~JsonValue();
172 
182  bool init(Type type);
183 
193  bool init(const std::string& value);
194 
204  bool init(const char* value) { return init(std::string(value)); }
205 
215  bool init(bool value);
216 
226  bool init(long value);
227 
237  bool init(double value);
238 
246  bool initNull() { return init(Type::NullType); }
247 
256  bool initArray() { return init(Type::ArrayType); }
257 
266  bool initObject() { return init(Type::ObjectType); }
267 
284  bool initWithJson(const std::string& json) {
285  return initWithJson(json.c_str());
286  }
287 
304  bool initWithJson(const char* json);
305 
306 
307 #pragma mark -
308 #pragma mark Static Constructors
309 
318  static std::shared_ptr<JsonValue> alloc(Type type) {
319  std::shared_ptr<JsonValue> result = std::make_shared<JsonValue>();
320  return (result->init(type) ? result : nullptr);
321  }
322 
332  static std::shared_ptr<JsonValue> alloc(const std::string& value) {
333  std::shared_ptr<JsonValue> result = std::make_shared<JsonValue>();
334  return (result->init(value) ? result : nullptr);
335  }
336 
346  static std::shared_ptr<JsonValue> alloc(const char* value) {
347  std::shared_ptr<JsonValue> result = std::make_shared<JsonValue>();
348  return (result->init(value) ? result : nullptr);
349  }
350 
360  static std::shared_ptr<JsonValue> alloc(bool value) {
361  std::shared_ptr<JsonValue> result = std::make_shared<JsonValue>();
362  return (result->init(value) ? result : nullptr);
363  }
364 
374  static std::shared_ptr<JsonValue> alloc(long value) {
375  std::shared_ptr<JsonValue> result = std::make_shared<JsonValue>();
376  return (result->init(value) ? result : nullptr);
377  }
378 
388  static std::shared_ptr<JsonValue> alloc(double value) {
389  std::shared_ptr<JsonValue> result = std::make_shared<JsonValue>();
390  return (result->init(value) ? result : nullptr);
391  }
392 
400  static std::shared_ptr<JsonValue> allocNull() {
401  std::shared_ptr<JsonValue> result = std::make_shared<JsonValue>();
402  return (result->initNull() ? result : nullptr);
403  }
404 
413  static std::shared_ptr<JsonValue> allocArray() {
414  std::shared_ptr<JsonValue> result = std::make_shared<JsonValue>();
415  return (result->initArray() ? result : nullptr);
416  }
417 
426  static std::shared_ptr<JsonValue> allocObject() {
427  std::shared_ptr<JsonValue> result = std::make_shared<JsonValue>();
428  return (result->initObject() ? result : nullptr);
429  }
430 
447  static std::shared_ptr<JsonValue> allocWithJson(const std::string& json) {
448  std::shared_ptr<JsonValue> result = std::make_shared<JsonValue>();
449  return (result->initWithJson(json) ? result : nullptr);
450  }
451 
468  static std::shared_ptr<JsonValue> allocWithJson(const char* json) {
469  std::shared_ptr<JsonValue> result = std::make_shared<JsonValue>();
470  return (result->initWithJson(json) ? result : nullptr);
471  }
472 
473 
474 #pragma mark -
475 #pragma mark Type
476 
481  Type type() const { return _type; }
482 
488  bool isNull() const { return _type == Type::NullType; }
489 
495  bool isNumber() const { return _type == Type::NumberType; }
496 
502  bool isBool() const { return _type == Type::BoolType; }
503 
509  bool isString() const { return _type == Type::StringType; }
510 
516  bool isValue() const;
517 
526  bool isArray() const { return _type == Type::ArrayType; }
527 
536  bool isObject() const { return _type == Type::ObjectType; }
537 
538 
539 #pragma mark -
540 #pragma mark Value Access
541 
551  const std::string asString(const std::string& defaultValue) const {
552  return asString(defaultValue.c_str());
553  }
554 
565  const std::string asString(const char* defaultValue="") const;
566 
577  float asFloat(float defaultValue=0.0f) const;
578 
589  double asDouble(double defaultValue=0.0) const;
590 
601  long asLong(long defaultValue=0L) const;
602 
613  int asInt(int defaultValue=0) const;
614 
626  bool asBool(bool defaultValue=false) const;
627 
639  std::vector<std::string> asStringArray(const std::string& defaultValue) const;
640 
652  std::vector<std::string> asStringArray(const char* defaultValue="") const {
653  return asStringArray(std::string(defaultValue));
654  }
655 
667  std::vector<float> asFloatArray(float defaultValue=0.0f) const;
668 
680  std::vector<double> asDoubleArray(double defaultValue=0.0) const;
681 
693  std::vector<long> asLongArray(long defaultValue=0L) const;
694 
706  std::vector<int> asIntArray(int defaultValue=0) const;
707 
719  std::vector<bool> asBoolArray (bool defaultValue=false);
720 
721 
722 #pragma mark -
723 #pragma mark Value Modification
724 
732  void set(const std::string& value);
733 
742  void set(const char* value) {
743  set(std::string(value));
744  }
745 
754  void set(long value);
755 
764  void set(double value);
765 
774  void set(bool value);
775 
782  void setNull();
783 
784 
785 #pragma mark -
786 #pragma mark Child Access
787 
795  const std::string& key() const;
796 
805  void setKey(const std::string& key);
806 
815  void setKey(const char* key) { setKey(std::string(key)); }
816 
824  const int index() const;
825 
831  size_t size() const { return _children.size(); }
832 
842  bool has(const std::string& name) const;
843 
853  bool has(const char* name) const {
854  return has(std::string(name));
855  }
856 
867  std::shared_ptr<JsonValue> get(int index);
868 
879  const std::shared_ptr<JsonValue> get(int index) const;
880 
893  std::shared_ptr<JsonValue> get(const std::string& name);
894 
907  const std::shared_ptr<JsonValue> get(const std::string& name) const;
908 
921  std::shared_ptr<JsonValue> get(const char* name) {
922  return get(std::string(name));
923  }
924 
937  const std::shared_ptr<JsonValue> get(const char* name) const {
938  return get(std::string(name));
939  }
940 
941 
942 #pragma mark -
943 #pragma mark Child Values
944 
957  const std::string getString (const std::string& key, const std::string& defaultValue) const;
958 
972  const std::string getString (const char* key, const char* defaultValue="") const {
973  return getString(std::string(key),std::string(defaultValue));
974  }
975 
989  const std::string getString (const std::string& key, const char* defaultValue="") const {
990  return getString(key,std::string(defaultValue));
991  }
992 
1006  const std::string getString (const char* key, const std::string& defaultValue) const {
1007  return getString(std::string(key),defaultValue);
1008  }
1009 
1023  float getFloat(const std::string& key, float defaultValue=0.0f) const;
1024 
1038  float getFloat(const char* key, float defaultValue=0.0f) const {
1039  return getFloat(std::string(key),defaultValue);
1040  }
1041 
1055  double getDouble(const std::string& key, double defaultValue=0.0) const;
1056 
1070  double getDouble(const char* key, double defaultValue=0.0) const {
1071  return getDouble(std::string(key),defaultValue);
1072  }
1073 
1087  long getLong(const std::string& key, long defaultValue=0L) const;
1088 
1102  long getLong(const char* key, long defaultValue=0L) const {
1103  return getLong(std::string(key),defaultValue);
1104  }
1105 
1119  int getInt(const std::string& key, int defaultValue=0) const;
1120 
1134  int getInt(const char* key, int defaultValue=0) const {
1135  return getInt(std::string(key),defaultValue);
1136  }
1137 
1151  bool getBool(const std::string& key, bool defaultValue=false) const;
1152 
1166  bool getBool(const char* key, bool defaultValue=false) const {
1167  return getBool(std::string(key),defaultValue);
1168  }
1169 
1170 #pragma mark -
1171 #pragma mark Child Deletion
1172 
1184  std::shared_ptr<JsonValue> removeChild(int index);
1185 
1198  std::shared_ptr<JsonValue> removeChild(const std::string& name);
1199 
1212  std::shared_ptr<JsonValue> removeChild(const char* name) {
1213  return removeChild(std::string(name));
1214  }
1215 
1216 #pragma mark -
1217 #pragma mark Child Addition
1218 
1232  void appendChild(const std::shared_ptr<JsonValue>& child);
1233 
1250  void appendChild(const std::string& key, const std::shared_ptr<JsonValue>& child);
1251 
1268  void appendChild(const char* key, const std::shared_ptr<JsonValue>& child) {
1269  return appendChild(std::string(key),child);
1270  }
1271 
1288  void insertChild(unsigned int index, const std::shared_ptr<JsonValue>& child);
1289 
1308  void insertChild(unsigned int index, const std::string& key, const std::shared_ptr<JsonValue>& child);
1309 
1328  void insertChild(unsigned int index, const char* key, const std::shared_ptr<JsonValue>& child) {
1329  insertChild(index,std::string(key),child);
1330  }
1331 
1342  void appendValue(bool value) {
1343  appendChild(JsonValue::alloc(value));
1344  }
1345 
1359  void appendValue(const std::string& key, bool value) {
1360  appendChild(key,JsonValue::alloc(value));
1361  }
1362 
1376  void appendValue(const char* key, bool value) {
1377  appendChild(key,JsonValue::alloc(value));
1378  }
1379 
1392  void insertValue(unsigned int index, bool value) {
1393  insertChild(index,JsonValue::alloc(value));
1394  }
1395 
1411  void insertValue(unsigned int index, const std::string& key, bool value) {
1412  insertChild(index,JsonValue::alloc(value));
1413  }
1414 
1430  void insertValue(unsigned int index, const char* key, bool value) {
1431  insertChild(index,JsonValue::alloc(value));
1432  }
1433 
1444  void appendValue(long value) {
1445  appendChild(JsonValue::alloc(value));
1446  }
1447 
1461  void appendValue(const std::string& key, long value) {
1462  appendChild(key,JsonValue::alloc(value));
1463  }
1464 
1478  void appendValue(const char* key, long value) {
1479  appendChild(key,JsonValue::alloc(value));
1480  }
1481 
1494  void insertValue(unsigned int index, long value) {
1495  insertChild(index,JsonValue::alloc(value));
1496  }
1497 
1513  void insertValue(unsigned int index, const std::string& key, long value) {
1514  insertChild(index,JsonValue::alloc(value));
1515  }
1516 
1532  void insertValue(unsigned int index, const char* key, long value) {
1533  insertChild(index,JsonValue::alloc(value));
1534  }
1535 
1546  void appendValue(double value) {
1547  appendChild(JsonValue::alloc(value));
1548  }
1549 
1563  void appendValue(const std::string& key, double value) {
1564  appendChild(key,JsonValue::alloc(value));
1565  }
1566 
1580  void appendValue(const char* key, double value) {
1581  appendChild(key,JsonValue::alloc(value));
1582  }
1583 
1596  void insertValue(unsigned int index, double value) {
1597  insertChild(index,JsonValue::alloc(value));
1598  }
1599 
1615  void insertValue(unsigned int index, const std::string& key, double value) {
1616  insertChild(index,JsonValue::alloc(value));
1617  }
1618 
1634  void insertValue(unsigned int index, const char* key, double value) {
1635  insertChild(index,JsonValue::alloc(value));
1636  }
1637 
1648  void appendValue(const std::string& value) {
1649  appendChild(JsonValue::alloc(value));
1650  }
1651 
1662  void appendValue(const char* value) {
1663  appendChild(JsonValue::alloc(value));
1664  }
1665 
1679  void appendValue(const std::string& key, const std::string& value) {
1680  appendChild(key,JsonValue::alloc(value));
1681  }
1682 
1696  void appendValue(const std::string& key, const char* value) {
1697  appendChild(key,JsonValue::alloc(value));
1698  }
1699 
1713  void appendValue(const char* key, const std::string& value) {
1714  appendChild(key,JsonValue::alloc(value));
1715  }
1716 
1730  void appendValue(const char* key, const char* value) {
1731  appendChild(key,JsonValue::alloc(value));
1732  }
1733 
1746  void insertValue(unsigned int index, const std::string& value) {
1747  insertChild(index,JsonValue::alloc(value));
1748  }
1749 
1762  void insertValue(unsigned int index, const char* value) {
1763  insertChild(index,JsonValue::alloc(value));
1764  }
1765 
1781  void insertValue(unsigned int index, const std::string& key, const std::string& value) {
1782  insertChild(index,JsonValue::alloc(value));
1783  }
1784 
1800  void insertValue(unsigned int index, const std::string& key, const char* value) {
1801  insertChild(index,JsonValue::alloc(value));
1802  }
1803 
1819  void insertValue(unsigned int index, const char* key, const std::string& value) {
1820  insertChild(index,JsonValue::alloc(value));
1821  }
1822 
1838  void insertValue(unsigned int index, const char* key, const char* value) {
1839  insertChild(index,JsonValue::alloc(value));
1840  }
1841 
1842 
1851  void appendNull() {
1853  }
1854 
1867  void appendNull(const std::string& key) {
1869  }
1870 
1883  void appendNull(const char* key) {
1885  }
1886 
1898  void insertNull(unsigned int index) {
1900  }
1901 
1916  void insertNull(unsigned int index, const std::string& key) {
1918  }
1919 
1934  void insertNull(unsigned int index, const char* key) {
1936  }
1937 
1946  void appendArray() {
1948  }
1949 
1962  void appendArray(const std::string& key) {
1964  }
1965 
1978  void appendArray(const char* key) {
1980  }
1981 
1993  void insertArray(unsigned int index) {
1995  }
1996 
2011  void insertArray(unsigned int index, const std::string& key) {
2012  insertChild(index,key,JsonValue::allocArray());
2013  }
2014 
2029  void insertArray(unsigned int index, const char* key) {
2030  insertChild(index,key,JsonValue::allocArray());
2031  }
2032 
2041  void appendObject() {
2043  }
2044 
2057  void appendObject(const std::string& key) {
2059  }
2060 
2073  void appendObject(const char* key) {
2075  }
2076 
2088  void insertObject(unsigned int index) {
2090  }
2091 
2106  void insertObject(unsigned int index, const std::string& key) {
2107  insertChild(index,key,JsonValue::allocObject());
2108  }
2109 
2124  void insertObject(unsigned int index, const char* key) {
2125  insertChild(index,key,JsonValue::allocObject());
2126  }
2127 
2128 
2129 #pragma mark -
2130 #pragma mark Encoding
2131 
2146  std::string toString(bool format=true) const;
2147 
2148 };
2149 
2150 }
2151 #endif /* __CU_JSON_VALUE_H__ */
void insertNull(unsigned int index)
Definition: CUJsonValue.h:1898
bool getBool(const std::string &key, bool defaultValue=false) const
void insertValue(unsigned int index, const std::string &key, long value)
Definition: CUJsonValue.h:1513
bool has(const std::string &name) const
const std::string getString(const std::string &key, const char *defaultValue="") const
Definition: CUJsonValue.h:989
int getInt(const char *key, int defaultValue=0) const
Definition: CUJsonValue.h:1134
void appendValue(const std::string &key, const std::string &value)
Definition: CUJsonValue.h:1679
static std::shared_ptr< JsonValue > alloc(const char *value)
Definition: CUJsonValue.h:346
void appendObject(const std::string &key)
Definition: CUJsonValue.h:2057
void insertValue(unsigned int index, const std::string &key, const char *value)
Definition: CUJsonValue.h:1800
static std::shared_ptr< JsonValue > allocArray()
Definition: CUJsonValue.h:413
void appendArray(const char *key)
Definition: CUJsonValue.h:1978
static std::shared_ptr< JsonValue > allocNull()
Definition: CUJsonValue.h:400
void insertObject(unsigned int index, const std::string &key)
Definition: CUJsonValue.h:2106
static std::shared_ptr< JsonValue > alloc(const std::string &value)
Definition: CUJsonValue.h:332
void appendValue(const std::string &key, bool value)
Definition: CUJsonValue.h:1359
static std::shared_ptr< JsonValue > alloc(bool value)
Definition: CUJsonValue.h:360
void insertValue(unsigned int index, const std::string &key, const std::string &value)
Definition: CUJsonValue.h:1781
void insertValue(unsigned int index, const std::string &key, bool value)
Definition: CUJsonValue.h:1411
float getFloat(const char *key, float defaultValue=0.0f) const
Definition: CUJsonValue.h:1038
static std::shared_ptr< JsonValue > alloc(Type type)
Definition: CUJsonValue.h:318
bool asBool(bool defaultValue=false) const
bool initArray()
Definition: CUJsonValue.h:256
void appendValue(const char *value)
Definition: CUJsonValue.h:1662
bool isNumber() const
Definition: CUJsonValue.h:495
static std::shared_ptr< JsonValue > alloc(double value)
Definition: CUJsonValue.h:388
std::string toString(bool format=true) const
void insertValue(unsigned int index, const std::string &key, double value)
Definition: CUJsonValue.h:1615
long getLong(const std::string &key, long defaultValue=0L) const
void appendValue(const char *key, double value)
Definition: CUJsonValue.h:1580
void appendArray(const std::string &key)
Definition: CUJsonValue.h:1962
void setKey(const char *key)
Definition: CUJsonValue.h:815
void insertValue(unsigned int index, const char *key, double value)
Definition: CUJsonValue.h:1634
std::vector< float > asFloatArray(float defaultValue=0.0f) const
const std::string & key() const
void appendNull(const std::string &key)
Definition: CUJsonValue.h:1867
bool init(const char *value)
Definition: CUJsonValue.h:204
bool initObject()
Definition: CUJsonValue.h:266
void appendNull(const char *key)
Definition: CUJsonValue.h:1883
void insertValue(unsigned int index, const char *key, bool value)
Definition: CUJsonValue.h:1430
std::vector< long > asLongArray(long defaultValue=0L) const
void appendValue(long value)
Definition: CUJsonValue.h:1444
bool isString() const
Definition: CUJsonValue.h:509
void set(const std::string &value)
void insertValue(unsigned int index, bool value)
Definition: CUJsonValue.h:1392
static std::shared_ptr< JsonValue > allocObject()
Definition: CUJsonValue.h:426
void appendValue(const std::string &key, double value)
Definition: CUJsonValue.h:1563
int getInt(const std::string &key, int defaultValue=0) const
bool isArray() const
Definition: CUJsonValue.h:526
long asLong(long defaultValue=0L) const
void appendChild(const std::shared_ptr< JsonValue > &child)
std::vector< bool > asBoolArray(bool defaultValue=false)
void insertValue(unsigned int index, const char *key, const std::string &value)
Definition: CUJsonValue.h:1819
static std::shared_ptr< JsonValue > alloc(long value)
Definition: CUJsonValue.h:374
void insertValue(unsigned int index, const char *key, const char *value)
Definition: CUJsonValue.h:1838
const std::string getString(const std::string &key, const std::string &defaultValue) const
Definition: CUJsonValue.h:68
void insertObject(unsigned int index)
Definition: CUJsonValue.h:2088
void insertValue(unsigned int index, const std::string &value)
Definition: CUJsonValue.h:1746
int asInt(int defaultValue=0) const
size_t size() const
Definition: CUJsonValue.h:831
void appendValue(const char *key, bool value)
Definition: CUJsonValue.h:1376
void appendArray()
Definition: CUJsonValue.h:1946
void appendValue(const std::string &key, long value)
Definition: CUJsonValue.h:1461
bool has(const char *name) const
Definition: CUJsonValue.h:853
bool isBool() const
Definition: CUJsonValue.h:502
void appendValue(const std::string &value)
Definition: CUJsonValue.h:1648
void appendObject()
Definition: CUJsonValue.h:2041
void insertNull(unsigned int index, const std::string &key)
Definition: CUJsonValue.h:1916
const std::string getString(const char *key, const std::string &defaultValue) const
Definition: CUJsonValue.h:1006
static std::shared_ptr< JsonValue > allocWithJson(const std::string &json)
Definition: CUJsonValue.h:447
bool init(Type type)
const std::string asString(const std::string &defaultValue) const
Definition: CUJsonValue.h:551
void insertChild(unsigned int index, const std::shared_ptr< JsonValue > &child)
void set(const char *value)
Definition: CUJsonValue.h:742
Type
Definition: CUJsonValue.h:77
std::shared_ptr< JsonValue > removeChild(const char *name)
Definition: CUJsonValue.h:1212
void appendNull()
Definition: CUJsonValue.h:1851
void setKey(const std::string &key)
std::vector< double > asDoubleArray(double defaultValue=0.0) const
double getDouble(const char *key, double defaultValue=0.0) const
Definition: CUJsonValue.h:1070
std::vector< int > asIntArray(int defaultValue=0) const
void insertValue(unsigned int index, double value)
Definition: CUJsonValue.h:1596
std::vector< std::string > asStringArray(const std::string &defaultValue) const
void appendValue(bool value)
Definition: CUJsonValue.h:1342
void appendValue(const char *key, long value)
Definition: CUJsonValue.h:1478
std::vector< std::string > asStringArray(const char *defaultValue="") const
Definition: CUJsonValue.h:652
static std::shared_ptr< JsonValue > allocWithJson(const char *json)
Definition: CUJsonValue.h:468
float getFloat(const std::string &key, float defaultValue=0.0f) const
void appendValue(double value)
Definition: CUJsonValue.h:1546
void insertValue(unsigned int index, const char *value)
Definition: CUJsonValue.h:1762
void appendValue(const std::string &key, const char *value)
Definition: CUJsonValue.h:1696
bool getBool(const char *key, bool defaultValue=false) const
Definition: CUJsonValue.h:1166
void insertNull(unsigned int index, const char *key)
Definition: CUJsonValue.h:1934
bool initNull()
Definition: CUJsonValue.h:246
Definition: CUAnimationNode.h:52
const std::string getString(const char *key, const char *defaultValue="") const
Definition: CUJsonValue.h:972
void insertArray(unsigned int index)
Definition: CUJsonValue.h:1993
void insertChild(unsigned int index, const char *key, const std::shared_ptr< JsonValue > &child)
Definition: CUJsonValue.h:1328
const int index() const
long getLong(const char *key, long defaultValue=0L) const
Definition: CUJsonValue.h:1102
Type type() const
Definition: CUJsonValue.h:481
double asDouble(double defaultValue=0.0) const
void appendValue(const char *key, const std::string &value)
Definition: CUJsonValue.h:1713
std::shared_ptr< JsonValue > removeChild(int index)
bool isObject() const
Definition: CUJsonValue.h:536
void appendValue(const char *key, const char *value)
Definition: CUJsonValue.h:1730
void insertArray(unsigned int index, const std::string &key)
Definition: CUJsonValue.h:2011
bool isNull() const
Definition: CUJsonValue.h:488
void insertValue(unsigned int index, long value)
Definition: CUJsonValue.h:1494
void insertValue(unsigned int index, const char *key, long value)
Definition: CUJsonValue.h:1532
double getDouble(const std::string &key, double defaultValue=0.0) const
bool initWithJson(const std::string &json)
Definition: CUJsonValue.h:284
void appendChild(const char *key, const std::shared_ptr< JsonValue > &child)
Definition: CUJsonValue.h:1268
float asFloat(float defaultValue=0.0f) const
void insertObject(unsigned int index, const char *key)
Definition: CUJsonValue.h:2124
bool isValue() const
void appendObject(const char *key)
Definition: CUJsonValue.h:2073
void insertArray(unsigned int index, const char *key)
Definition: CUJsonValue.h:2029