CUGL 1.2
Cornell University Game Library
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
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 MIT 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 <cugl/base/CUBase.h>
47 #include <cJSON/cJSON.h>
48 #include <vector>
49 #include <string>
50 
51 namespace cugl {
52 
69 class JsonValue {
70 public:
78  enum class Type : int {
80  NullType = 0,
82  BoolType = 1,
84  NumberType = 2,
86  StringType = 3,
88  ArrayType = 4,
90  ObjectType = 5
91  };
92 
93 private:
95  Type _type;
96 
98  JsonValue* _parent;
100  std::string _key;
101 
103  std::string _stringValue;
105  long _longValue;
107  double _doubleValue;
108 
110  std::vector<std::shared_ptr<JsonValue>> _children;
111 
112 #pragma mark -
113 #pragma mark cJSON Conversions
114 
127  static std::shared_ptr<JsonValue> toJsonValue(const cJSON* node);
128 
140  static void toJsonValue(JsonValue* value, const cJSON* node);
141 
153  static cJSON* toCJSON(const JsonValue* value);
154 
155 #pragma mark -
156 #pragma mark Constructors
157 public:
164  JsonValue();
165 
172  ~JsonValue();
173 
183  bool init(Type type);
184 
194  bool init(const std::string& value);
195 
205  bool init(const char* value) { return init(std::string(value)); }
206 
216  bool init(bool value);
217 
227  bool init(long value);
228 
238  bool init(double value);
239 
247  bool initNull() { return init(Type::NullType); }
248 
257  bool initArray() { return init(Type::ArrayType); }
258 
267  bool initObject() { return init(Type::ObjectType); }
268 
285  bool initWithJson(const std::string& json) {
286  return initWithJson(json.c_str());
287  }
288 
305  bool initWithJson(const char* json);
306 
307 
308 #pragma mark -
309 #pragma mark Static Constructors
310 
319  static std::shared_ptr<JsonValue> alloc(Type type) {
320  std::shared_ptr<JsonValue> result = std::make_shared<JsonValue>();
321  return (result->init(type) ? result : nullptr);
322  }
323 
333  static std::shared_ptr<JsonValue> alloc(const std::string& value) {
334  std::shared_ptr<JsonValue> result = std::make_shared<JsonValue>();
335  return (result->init(value) ? result : nullptr);
336  }
337 
347  static std::shared_ptr<JsonValue> alloc(const char* value) {
348  std::shared_ptr<JsonValue> result = std::make_shared<JsonValue>();
349  return (result->init(value) ? result : nullptr);
350  }
351 
361  static std::shared_ptr<JsonValue> alloc(bool value) {
362  std::shared_ptr<JsonValue> result = std::make_shared<JsonValue>();
363  return (result->init(value) ? result : nullptr);
364  }
365 
375  static std::shared_ptr<JsonValue> alloc(long value) {
376  std::shared_ptr<JsonValue> result = std::make_shared<JsonValue>();
377  return (result->init(value) ? result : nullptr);
378  }
379 
389  static std::shared_ptr<JsonValue> alloc(double value) {
390  std::shared_ptr<JsonValue> result = std::make_shared<JsonValue>();
391  return (result->init(value) ? result : nullptr);
392  }
393 
401  static std::shared_ptr<JsonValue> allocNull() {
402  std::shared_ptr<JsonValue> result = std::make_shared<JsonValue>();
403  return (result->initNull() ? result : nullptr);
404  }
405 
414  static std::shared_ptr<JsonValue> allocArray() {
415  std::shared_ptr<JsonValue> result = std::make_shared<JsonValue>();
416  return (result->initArray() ? result : nullptr);
417  }
418 
427  static std::shared_ptr<JsonValue> allocObject() {
428  std::shared_ptr<JsonValue> result = std::make_shared<JsonValue>();
429  return (result->initObject() ? result : nullptr);
430  }
431 
448  static std::shared_ptr<JsonValue> allocWithJson(const std::string& json) {
449  std::shared_ptr<JsonValue> result = std::make_shared<JsonValue>();
450  return (result->initWithJson(json) ? result : nullptr);
451  }
452 
469  static std::shared_ptr<JsonValue> allocWithJson(const char* json) {
470  std::shared_ptr<JsonValue> result = std::make_shared<JsonValue>();
471  return (result->initWithJson(json) ? result : nullptr);
472  }
473 
474 
475 #pragma mark -
476 #pragma mark Type
477 
482  Type type() const { return _type; }
483 
489  bool isNull() const { return _type == Type::NullType; }
490 
496  bool isNumber() const { return _type == Type::NumberType; }
497 
503  bool isBool() const { return _type == Type::BoolType; }
504 
510  bool isString() const { return _type == Type::StringType; }
511 
517  bool isValue() const;
518 
527  bool isArray() const { return _type == Type::ArrayType; }
528 
537  bool isObject() const { return _type == Type::ObjectType; }
538 
539 
540 #pragma mark -
541 #pragma mark Value Access
542 
552  const std::string asString(const std::string& defaultValue) const {
553  return asString(defaultValue.c_str());
554  }
555 
566  const std::string asString(const char* defaultValue="") const;
567 
578  float asFloat(float defaultValue=0.0f) const;
579 
590  double asDouble(double defaultValue=0.0) const;
591 
602  long asLong(long defaultValue=0L) const;
603 
614  int asInt(int defaultValue=0) const;
615 
627  bool asBool(bool defaultValue=false) const;
628 
640  std::vector<std::string> asStringArray(const std::string& defaultValue) const;
641 
653  std::vector<std::string> asStringArray(const char* defaultValue="") const {
654  return asStringArray(std::string(defaultValue));
655  }
656 
668  std::vector<float> asFloatArray(float defaultValue=0.0f) const;
669 
681  std::vector<double> asDoubleArray(double defaultValue=0.0) const;
682 
694  std::vector<long> asLongArray(long defaultValue=0L) const;
695 
707  std::vector<int> asIntArray(int defaultValue=0) const;
708 
720  std::vector<bool> asBoolArray (bool defaultValue=false);
721 
722 
723 #pragma mark -
724 #pragma mark Value Modification
725 
733  void set(const std::string& value);
734 
743  void set(const char* value) {
744  set(std::string(value));
745  }
746 
755  void set(long value);
756 
765  void set(double value);
766 
775  void set(bool value);
776 
783  void setNull();
784 
785 
786 #pragma mark -
787 #pragma mark Child Access
788 
796  const std::string& key() const;
797 
806  void setKey(const std::string& key);
807 
816  void setKey(const char* key) { setKey(std::string(key)); }
817 
825  const int index() const;
826 
832  size_t size() const { return _children.size(); }
833 
843  bool has(const std::string& name) const;
844 
854  bool has(const char* name) const {
855  return has(std::string(name));
856  }
857 
868  std::shared_ptr<JsonValue> get(int index);
869 
880  const std::shared_ptr<JsonValue> get(int index) const;
881 
894  std::shared_ptr<JsonValue> get(const std::string& name);
895 
908  const std::shared_ptr<JsonValue> get(const std::string& name) const;
909 
922  std::shared_ptr<JsonValue> get(const char* name) {
923  return get(std::string(name));
924  }
925 
938  const std::shared_ptr<JsonValue> get(const char* name) const {
939  return get(std::string(name));
940  }
941 
942 
943 #pragma mark -
944 #pragma mark Child Values
945 
958  const std::string getString (const std::string& key, const std::string& defaultValue) const;
959 
973  const std::string getString (const char* key, const char* defaultValue="") const {
974  return getString(std::string(key),std::string(defaultValue));
975  }
976 
990  const std::string getString (const std::string& key, const char* defaultValue="") const {
991  return getString(key,std::string(defaultValue));
992  }
993 
1007  const std::string getString (const char* key, const std::string& defaultValue) const {
1008  return getString(std::string(key),defaultValue);
1009  }
1010 
1024  float getFloat(const std::string& key, float defaultValue=0.0f) const;
1025 
1039  float getFloat(const char* key, float defaultValue=0.0f) const {
1040  return getFloat(std::string(key),defaultValue);
1041  }
1042 
1056  double getDouble(const std::string& key, double defaultValue=0.0) const;
1057 
1071  double getDouble(const char* key, double defaultValue=0.0) const {
1072  return getDouble(std::string(key),defaultValue);
1073  }
1074 
1088  long getLong(const std::string& key, long defaultValue=0L) const;
1089 
1103  long getLong(const char* key, long defaultValue=0L) const {
1104  return getLong(std::string(key),defaultValue);
1105  }
1106 
1120  int getInt(const std::string& key, int defaultValue=0) const;
1121 
1135  int getInt(const char* key, int defaultValue=0) const {
1136  return getInt(std::string(key),defaultValue);
1137  }
1138 
1152  bool getBool(const std::string& key, bool defaultValue=false) const;
1153 
1167  bool getBool(const char* key, bool defaultValue=false) const {
1168  return getBool(std::string(key),defaultValue);
1169  }
1170 
1171 #pragma mark -
1172 #pragma mark Child Deletion
1173 
1185  std::shared_ptr<JsonValue> removeChild(int index);
1186 
1199  std::shared_ptr<JsonValue> removeChild(const std::string& name);
1200 
1213  std::shared_ptr<JsonValue> removeChild(const char* name) {
1214  return removeChild(std::string(name));
1215  }
1216 
1217 #pragma mark -
1218 #pragma mark Child Addition
1219 
1233  void appendChild(const std::shared_ptr<JsonValue>& child);
1234 
1251  void appendChild(const std::string& key, const std::shared_ptr<JsonValue>& child);
1252 
1269  void appendChild(const char* key, const std::shared_ptr<JsonValue>& child) {
1270  return appendChild(std::string(key),child);
1271  }
1272 
1289  void insertChild(unsigned int index, const std::shared_ptr<JsonValue>& child);
1290 
1309  void insertChild(unsigned int index, const std::string& key, const std::shared_ptr<JsonValue>& child);
1310 
1329  void insertChild(unsigned int index, const char* key, const std::shared_ptr<JsonValue>& child) {
1330  insertChild(index,std::string(key),child);
1331  }
1332 
1343  void appendValue(bool value) {
1344  appendChild(JsonValue::alloc(value));
1345  }
1346 
1360  void appendValue(const std::string& key, bool value) {
1361  appendChild(key,JsonValue::alloc(value));
1362  }
1363 
1377  void appendValue(const char* key, bool value) {
1378  appendChild(key,JsonValue::alloc(value));
1379  }
1380 
1393  void insertValue(unsigned int index, bool value) {
1394  insertChild(index,JsonValue::alloc(value));
1395  }
1396 
1412  void insertValue(unsigned int index, const std::string& key, bool value) {
1413  insertChild(index,JsonValue::alloc(value));
1414  }
1415 
1431  void insertValue(unsigned int index, const char* key, bool value) {
1432  insertChild(index,JsonValue::alloc(value));
1433  }
1434 
1445  void appendValue(long value) {
1446  appendChild(JsonValue::alloc(value));
1447  }
1448 
1462  void appendValue(const std::string& key, long value) {
1463  appendChild(key,JsonValue::alloc(value));
1464  }
1465 
1479  void appendValue(const char* key, long value) {
1480  appendChild(key,JsonValue::alloc(value));
1481  }
1482 
1495  void insertValue(unsigned int index, long value) {
1496  insertChild(index,JsonValue::alloc(value));
1497  }
1498 
1514  void insertValue(unsigned int index, const std::string& key, long value) {
1515  insertChild(index,JsonValue::alloc(value));
1516  }
1517 
1533  void insertValue(unsigned int index, const char* key, long value) {
1534  insertChild(index,JsonValue::alloc(value));
1535  }
1536 
1547  void appendValue(double value) {
1548  appendChild(JsonValue::alloc(value));
1549  }
1550 
1564  void appendValue(const std::string& key, double value) {
1565  appendChild(key,JsonValue::alloc(value));
1566  }
1567 
1581  void appendValue(const char* key, double value) {
1582  appendChild(key,JsonValue::alloc(value));
1583  }
1584 
1597  void insertValue(unsigned int index, double value) {
1598  insertChild(index,JsonValue::alloc(value));
1599  }
1600 
1616  void insertValue(unsigned int index, const std::string& key, double value) {
1617  insertChild(index,JsonValue::alloc(value));
1618  }
1619 
1635  void insertValue(unsigned int index, const char* key, double value) {
1636  insertChild(index,JsonValue::alloc(value));
1637  }
1638 
1649  void appendValue(const std::string& value) {
1650  appendChild(JsonValue::alloc(value));
1651  }
1652 
1663  void appendValue(const char* value) {
1664  appendChild(JsonValue::alloc(value));
1665  }
1666 
1680  void appendValue(const std::string& key, const std::string& value) {
1681  appendChild(key,JsonValue::alloc(value));
1682  }
1683 
1697  void appendValue(const std::string& key, const char* value) {
1698  appendChild(key,JsonValue::alloc(value));
1699  }
1700 
1714  void appendValue(const char* key, const std::string& value) {
1715  appendChild(key,JsonValue::alloc(value));
1716  }
1717 
1731  void appendValue(const char* key, const char* value) {
1732  appendChild(key,JsonValue::alloc(value));
1733  }
1734 
1747  void insertValue(unsigned int index, const std::string& value) {
1748  insertChild(index,JsonValue::alloc(value));
1749  }
1750 
1763  void insertValue(unsigned int index, const char* value) {
1764  insertChild(index,JsonValue::alloc(value));
1765  }
1766 
1782  void insertValue(unsigned int index, const std::string& key, const std::string& value) {
1783  insertChild(index,JsonValue::alloc(value));
1784  }
1785 
1801  void insertValue(unsigned int index, const std::string& key, const char* value) {
1802  insertChild(index,JsonValue::alloc(value));
1803  }
1804 
1820  void insertValue(unsigned int index, const char* key, const std::string& value) {
1821  insertChild(index,JsonValue::alloc(value));
1822  }
1823 
1839  void insertValue(unsigned int index, const char* key, const char* value) {
1840  insertChild(index,JsonValue::alloc(value));
1841  }
1842 
1843 
1852  void appendNull() {
1854  }
1855 
1868  void appendNull(const std::string& key) {
1870  }
1871 
1884  void appendNull(const char* key) {
1886  }
1887 
1899  void insertNull(unsigned int index) {
1901  }
1902 
1917  void insertNull(unsigned int index, const std::string& key) {
1919  }
1920 
1935  void insertNull(unsigned int index, const char* key) {
1937  }
1938 
1947  void appendArray() {
1949  }
1950 
1963  void appendArray(const std::string& key) {
1965  }
1966 
1979  void appendArray(const char* key) {
1981  }
1982 
1994  void insertArray(unsigned int index) {
1996  }
1997 
2012  void insertArray(unsigned int index, const std::string& key) {
2013  insertChild(index,key,JsonValue::allocArray());
2014  }
2015 
2030  void insertArray(unsigned int index, const char* key) {
2031  insertChild(index,key,JsonValue::allocArray());
2032  }
2033 
2042  void appendObject() {
2044  }
2045 
2058  void appendObject(const std::string& key) {
2060  }
2061 
2074  void appendObject(const char* key) {
2076  }
2077 
2089  void insertObject(unsigned int index) {
2091  }
2092 
2107  void insertObject(unsigned int index, const std::string& key) {
2108  insertChild(index,key,JsonValue::allocObject());
2109  }
2110 
2125  void insertObject(unsigned int index, const char* key) {
2126  insertChild(index,key,JsonValue::allocObject());
2127  }
2128 
2129 
2130 #pragma mark -
2131 #pragma mark Encoding
2132 
2147  std::string toString(bool format=true) const;
2148 
2149 };
2150 
2151 }
2152 #endif /* __CU_JSON_VALUE_H__ */
void insertNull(unsigned int index)
Definition: CUJsonValue.h:1899
bool getBool(const std::string &key, bool defaultValue=false) const
void insertValue(unsigned int index, const std::string &key, long value)
Definition: CUJsonValue.h:1514
bool has(const std::string &name) const
const std::string getString(const std::string &key, const char *defaultValue="") const
Definition: CUJsonValue.h:990
int getInt(const char *key, int defaultValue=0) const
Definition: CUJsonValue.h:1135
void appendValue(const std::string &key, const std::string &value)
Definition: CUJsonValue.h:1680
static std::shared_ptr< JsonValue > alloc(const char *value)
Definition: CUJsonValue.h:347
void appendObject(const std::string &key)
Definition: CUJsonValue.h:2058
void insertValue(unsigned int index, const std::string &key, const char *value)
Definition: CUJsonValue.h:1801
static std::shared_ptr< JsonValue > allocArray()
Definition: CUJsonValue.h:414
void appendArray(const char *key)
Definition: CUJsonValue.h:1979
static std::shared_ptr< JsonValue > allocNull()
Definition: CUJsonValue.h:401
void insertObject(unsigned int index, const std::string &key)
Definition: CUJsonValue.h:2107
static std::shared_ptr< JsonValue > alloc(const std::string &value)
Definition: CUJsonValue.h:333
void appendValue(const std::string &key, bool value)
Definition: CUJsonValue.h:1360
static std::shared_ptr< JsonValue > alloc(bool value)
Definition: CUJsonValue.h:361
void insertValue(unsigned int index, const std::string &key, const std::string &value)
Definition: CUJsonValue.h:1782
void insertValue(unsigned int index, const std::string &key, bool value)
Definition: CUJsonValue.h:1412
float getFloat(const char *key, float defaultValue=0.0f) const
Definition: CUJsonValue.h:1039
static std::shared_ptr< JsonValue > alloc(Type type)
Definition: CUJsonValue.h:319
bool asBool(bool defaultValue=false) const
bool initArray()
Definition: CUJsonValue.h:257
void appendValue(const char *value)
Definition: CUJsonValue.h:1663
bool isNumber() const
Definition: CUJsonValue.h:496
static std::shared_ptr< JsonValue > alloc(double value)
Definition: CUJsonValue.h:389
std::string toString(bool format=true) const
void insertValue(unsigned int index, const std::string &key, double value)
Definition: CUJsonValue.h:1616
long getLong(const std::string &key, long defaultValue=0L) const
void appendValue(const char *key, double value)
Definition: CUJsonValue.h:1581
void appendArray(const std::string &key)
Definition: CUJsonValue.h:1963
void setKey(const char *key)
Definition: CUJsonValue.h:816
void insertValue(unsigned int index, const char *key, double value)
Definition: CUJsonValue.h:1635
std::vector< float > asFloatArray(float defaultValue=0.0f) const
const std::string & key() const
void appendNull(const std::string &key)
Definition: CUJsonValue.h:1868
bool init(const char *value)
Definition: CUJsonValue.h:205
bool initObject()
Definition: CUJsonValue.h:267
void appendNull(const char *key)
Definition: CUJsonValue.h:1884
void insertValue(unsigned int index, const char *key, bool value)
Definition: CUJsonValue.h:1431
std::vector< long > asLongArray(long defaultValue=0L) const
void appendValue(long value)
Definition: CUJsonValue.h:1445
bool isString() const
Definition: CUJsonValue.h:510
void set(const std::string &value)
void insertValue(unsigned int index, bool value)
Definition: CUJsonValue.h:1393
static std::shared_ptr< JsonValue > allocObject()
Definition: CUJsonValue.h:427
void appendValue(const std::string &key, double value)
Definition: CUJsonValue.h:1564
int getInt(const std::string &key, int defaultValue=0) const
bool isArray() const
Definition: CUJsonValue.h:527
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:1820
static std::shared_ptr< JsonValue > alloc(long value)
Definition: CUJsonValue.h:375
void insertValue(unsigned int index, const char *key, const char *value)
Definition: CUJsonValue.h:1839
const std::string getString(const std::string &key, const std::string &defaultValue) const
Definition: CUJsonValue.h:69
void insertObject(unsigned int index)
Definition: CUJsonValue.h:2089
void insertValue(unsigned int index, const std::string &value)
Definition: CUJsonValue.h:1747
int asInt(int defaultValue=0) const
size_t size() const
Definition: CUJsonValue.h:832
void appendValue(const char *key, bool value)
Definition: CUJsonValue.h:1377
void appendArray()
Definition: CUJsonValue.h:1947
void appendValue(const std::string &key, long value)
Definition: CUJsonValue.h:1462
bool has(const char *name) const
Definition: CUJsonValue.h:854
bool isBool() const
Definition: CUJsonValue.h:503
void appendValue(const std::string &value)
Definition: CUJsonValue.h:1649
void appendObject()
Definition: CUJsonValue.h:2042
void insertNull(unsigned int index, const std::string &key)
Definition: CUJsonValue.h:1917
const std::string getString(const char *key, const std::string &defaultValue) const
Definition: CUJsonValue.h:1007
static std::shared_ptr< JsonValue > allocWithJson(const std::string &json)
Definition: CUJsonValue.h:448
bool init(Type type)
const std::string asString(const std::string &defaultValue) const
Definition: CUJsonValue.h:552
void insertChild(unsigned int index, const std::shared_ptr< JsonValue > &child)
void set(const char *value)
Definition: CUJsonValue.h:743
Type
Definition: CUJsonValue.h:78
std::shared_ptr< JsonValue > removeChild(const char *name)
Definition: CUJsonValue.h:1213
void appendNull()
Definition: CUJsonValue.h:1852
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:1071
std::vector< int > asIntArray(int defaultValue=0) const
void insertValue(unsigned int index, double value)
Definition: CUJsonValue.h:1597
std::vector< std::string > asStringArray(const std::string &defaultValue) const
void appendValue(bool value)
Definition: CUJsonValue.h:1343
void appendValue(const char *key, long value)
Definition: CUJsonValue.h:1479
std::vector< std::string > asStringArray(const char *defaultValue="") const
Definition: CUJsonValue.h:653
static std::shared_ptr< JsonValue > allocWithJson(const char *json)
Definition: CUJsonValue.h:469
float getFloat(const std::string &key, float defaultValue=0.0f) const
void appendValue(double value)
Definition: CUJsonValue.h:1547
void insertValue(unsigned int index, const char *value)
Definition: CUJsonValue.h:1763
void appendValue(const std::string &key, const char *value)
Definition: CUJsonValue.h:1697
bool getBool(const char *key, bool defaultValue=false) const
Definition: CUJsonValue.h:1167
void insertNull(unsigned int index, const char *key)
Definition: CUJsonValue.h:1935
bool initNull()
Definition: CUJsonValue.h:247
Definition: CUAction.h:51
const std::string getString(const char *key, const char *defaultValue="") const
Definition: CUJsonValue.h:973
void insertArray(unsigned int index)
Definition: CUJsonValue.h:1994
void insertChild(unsigned int index, const char *key, const std::shared_ptr< JsonValue > &child)
Definition: CUJsonValue.h:1329
const int index() const
long getLong(const char *key, long defaultValue=0L) const
Definition: CUJsonValue.h:1103
Type type() const
Definition: CUJsonValue.h:482
double asDouble(double defaultValue=0.0) const
void appendValue(const char *key, const std::string &value)
Definition: CUJsonValue.h:1714
std::shared_ptr< JsonValue > removeChild(int index)
bool isObject() const
Definition: CUJsonValue.h:537
void appendValue(const char *key, const char *value)
Definition: CUJsonValue.h:1731
void insertArray(unsigned int index, const std::string &key)
Definition: CUJsonValue.h:2012
bool isNull() const
Definition: CUJsonValue.h:489
void insertValue(unsigned int index, long value)
Definition: CUJsonValue.h:1495
void insertValue(unsigned int index, const char *key, long value)
Definition: CUJsonValue.h:1533
double getDouble(const std::string &key, double defaultValue=0.0) const
bool initWithJson(const std::string &json)
Definition: CUJsonValue.h:285
void appendChild(const char *key, const std::shared_ptr< JsonValue > &child)
Definition: CUJsonValue.h:1269
float asFloat(float defaultValue=0.0f) const
void insertObject(unsigned int index, const char *key)
Definition: CUJsonValue.h:2125
bool isValue() const
void appendObject(const char *key)
Definition: CUJsonValue.h:2074
void insertArray(unsigned int index, const char *key)
Definition: CUJsonValue.h:2030