From 46c896bcd78d31130321562b0659e28230261b8e Mon Sep 17 00:00:00 2001 From: Dylan Date: Sat, 6 Jun 2026 18:05:19 +1200 Subject: feat: Initial commit, json data structure and serializing to json --- src/json.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/json.h (limited to 'src/json.h') diff --git a/src/json.h b/src/json.h new file mode 100644 index 0000000..d1d7938 --- /dev/null +++ b/src/json.h @@ -0,0 +1,40 @@ +#include +#include +#include +#include + +namespace TehJSON +{ + class JSON + { + public: + JSON(); + JSON(const JSON& other) = default; + ~JSON(); + + // Leaf methods + template + T& get(); + template + void set(T value); + std::string leafType(); + std::string getSerialized(); + std::string _getSerialized(int currIndent); + template + static std::string serializeData(std::shared_ptr data); + + // Non leaf methods + JSON& operator[](std::string name); + size_t childCount(); + // std::vector childNames(); + private: + bool isLeaf = false; + + // Leaf data fields + std::shared_ptr data; + std::string (*dataSerializer)(std::shared_ptr); + + // Not leaf data fields + std::map children; + }; +} -- cgit v1.2.3