JSON value aliases, serialization helpers, and file utilities built on nlohmann/json.
| Name | Description |
|---|---|
Configuration | JSON configuration file |
ISerializable | Abstract interface for JSON-serializable objects. |
| Return | Name | Description |
|---|---|---|
nlohmann::json | Value | Primary JSON value type used throughout the library. |
nlohmann::json Value()Primary JSON value type used throughout the library.
| Return | Name | Description |
|---|---|---|
bool | serialize inline | Serializes pObj to a pretty-printed JSON string. |
bool | deserialize inline | Deserializes pObj from a JSON string. |
void | loadFile inline | Load a JSON file into a value. Throws on missing file or parse error. |
void | saveFile inline | Save a JSON value to a file. Throws on write error. |
void | assertMember inline | Assert that a required member exists. Throws if missing. |
void | countNestedKeys inline | Count how many nested objects contain the given key. |
bool | hasNestedKey inline | Return true if any nested object contains the given key. |
bool | findNestedObjectWithProperty inline | Find a nested object whose property matches the given key/value. |
inline
inline bool serialize(ISerializable * pObj, std::string & output)Serializes pObj to a pretty-printed JSON string.
pObj Object to serialize; must not be null.
output Receives the 4-space indented JSON string.
true on success, false if pObj is null.
inline
inline bool deserialize(ISerializable * pObj, std::string & input)Deserializes pObj from a JSON string.
pObj Object to populate; must not be null.
input JSON string to parse.
true on success, false if pObj is null or parsing fails.
inline
inline void loadFile(const std::string & path, json::Value & root)Load a JSON file into a value. Throws on missing file or parse error.
inline
inline void saveFile(const std::string & path, const json::Value & root, int indent)Save a JSON value to a file. Throws on write error.
inline
inline void assertMember(const json::Value & root, const std::string & name)Assert that a required member exists. Throws if missing.
inline
inline void countNestedKeys(const json::Value & root, const std::string & key, int & count)Count how many nested objects contain the given key.
inline
inline bool hasNestedKey(const json::Value & root, const std::string & key)Return true if any nested object contains the given key.
inline
inline bool findNestedObjectWithProperty(json::Value & root, json::Value *& result, std::string_view key, std::string_view value, bool partial, int index)Find a nested object whose property matches the given key/value.
Key or value may be empty for wildcard matching. If partial is true, substring matches are accepted for string values. The index parameter selects the Nth match (0 = first).
Returns true if found, with result pointing to the matching object.