JSONObject.h 589 B

123456789101112131415161718192021222324252627282930313233
  1. #ifndef JSONOBJECT_H
  2. #define JSONOBJECT_H
  3. #include <cJSON.h>
  4. #include <string>
  5. namespace bell {
  6. class JSONValue
  7. {
  8. public:
  9. JSONValue(cJSON* body, std::string key);
  10. void operator=(const std::string val);
  11. void operator=(const char* val);
  12. void operator=(int val);
  13. private:
  14. cJSON* body;
  15. std::string key;
  16. };
  17. class JSONObject
  18. {
  19. public:
  20. JSONObject();
  21. ~JSONObject();
  22. JSONValue operator[](std::string index);
  23. std::string toString();
  24. private:
  25. cJSON* body;
  26. };
  27. }
  28. #endif