Util: Add parse() and dump() to Json::Value

This commit is contained in:
Riyyi
2022-06-23 13:45:07 +02:00
parent aad95de5fd
commit 9f7fe81ef6
2 changed files with 57 additions and 3 deletions
+12 -2
View File
@@ -7,6 +7,8 @@
#ifndef JSON_VALUE_H
#define JSON_VALUE_H
#include <cstdint> // uint32_t
#include <iostream> // istream, ostream
#include <string>
namespace Json {
@@ -25,7 +27,7 @@ public:
Object, // {}
};
Value() {}
Value(std::nullptr_t = nullptr) {}
virtual ~Value() { clear(); }
// Copy constructor
@@ -40,6 +42,11 @@ public:
Value(const Array& value);
Value(const Object& value);
// ------------------------------------------
static Value parse(const std::string& input);
std::string dump(const uint32_t indent = 0, const char indentCharacter = ' ') const;
// Array index operator
Value operator[](size_t index);
Value operator[](const std::string& key);
@@ -64,9 +71,12 @@ private:
std::string* asString;
Array* asArray;
Object* asObject;
} m_value;
} m_value {};
};
std::istream& operator>>(std::istream& input, Value& value);
std::ostream& operator<<(std::ostream& output, const Value& value);
} // namespace Json
#endif // JSON_VALUE_H