A lightweight JSON parser library written in C++17.
- Parse JSON from string or file
- Support for all JSON types: null, boolean, number, string, array, object
- Simple and intuitive API
- Header-only style usage
.
├── include/
│ ├── jsonparser.h # Header file
│ └── jsonparser.cpp # Implementation
└── test.cpp # Test program
#include "jsonread.h"
int main() {
jsonread::JsonParser parser;
// Parse from file
auto json = parser.parseFile("data.json");
double value = json["key"].asNumber();
// Parse from string
auto json2 = parser.parse(R"({"name": "test", "value": 123})");
std::string name = json2["name"].asString();
// Access nested values
auto nested = json2["data"]["x"].asNumber();
// Access array elements
auto arrElement = json2["arr"][0].asNumber();
return 0;
}isNull(),isBool(),isNumber(),isString(),isArray(),isObject()- Type checkingasBool(),asNumber(),asString(),asArray(),asObject()- Get valueasInt(),asBoolOpt()- Optional type conversionoperator[]- Access object keys or array indices
parse(const std::string& jsonStr)- Parse JSON stringparseFile(const char* filePath)- Parse JSON file
- C++17 compatible compiler
- g++ or gcc