app/json_lite.h

a tiny, dependency-free JSON reader.

The GUI’s personality files are the only JSON the app consumes, and the appliance build is deliberately lean (no vendored third-party libs), so rather than pull in a full JSON library we parse the small, fixed schema in §4 of docs/gui-docs/PLAN.md with this self-contained recursive-descent reader. It supports the full JSON grammar (objects, arrays, strings with escapes, numbers, true/false/null) but is read-only — there is no serializer.

namespace kirin
namespace json

Enums

enum class Type

Values:

enumerator Null
enumerator Bool
enumerator Number
enumerator String
enumerator Array
enumerator Object
class Value
#include <json_lite.h>

Public Functions

Value() = default
inline Type type() const
inline bool isNull() const
inline bool isBool() const
inline bool isNumber() const
inline bool isString() const
inline bool isArray() const
inline bool isObject() const
inline bool asBool(bool fallback = false) const
inline double asNumber(double fallback = 0.0) const
inline int asInt(int fallback = 0) const
inline long asLong(long fallback = 0) const
inline const std::string &asString(const std::string &fallback = kEmpty) const
const Value &operator[](const std::string &key) const
bool contains(const std::string &key) const
inline const std::vector<Value> &items() const
inline size_t size() const

Public Static Functions

static inline Value makeNull()
static Value makeBool(bool b)
static Value makeNumber(double n)
static Value makeString(std::string s)
static Value makeArray(std::vector<Value> a)
static Value makeObject(std::map<std::string, Value> o)

Private Members

Type type_ = Type::Null
bool bool_ = false
double num_ = 0.0
std::string str_
std::vector<Value> arr_
std::map<std::string, Value> obj_

Private Static Attributes

static const std::string kEmpty
static const Value kNull