JSON library written with C++ features
简体中文 | English
Why write such a JSON library? github currently has a lot of large JSON parsing library, such as RapidJSON, jsoncpp, nlohmann_json, but due to history and other force majeure reasons, they have their own shortcomings and shortcomings, a variety of a wide range of code pile up, resulting in maintenance difficulties, I am committed to creating a code the most simple, fast, portable JSON library. Fast, portable JSON library.
- a hundred polished API
- use std::variant for operations, memory-friendly
- has a slightly higher efficiency than nlohmann
- The code follows
Google C++ Style
- add
json.cpp
andjson.h
to your project - adjust the project's language standard to
c++17
or newer - Include
json.h
in your.c
or.cpp
file
- Value Used to store, query and modify JSON data
- Parser Used to parse a JSON string into Value
Parser p.
Value v.
if (!p.parse(s, v))
cout << p.getError() << endl.
- Writer Used to serialize Value objects into JSON strings
Writer w.
Value v.
w.writeValue(v).
cout << w.getOutput() << endl.
Of course you can also use Value::dump() for this function
If you want to configure serialization mode, you have to use this example
https://github.com/jo-qzy/MyJson/ https://github.com/open-source-parsers/jsoncpp https://github.com/nlohmann/json
Translated with www.DeepL.com/Translator (free version)