jansson 2.11-2 Jansson is a C library for encoding, decoding and manipulating JSON data
json-spirit 4.1.0-1 json parser using boost library
json11 2017-06-20 json11 is a tiny JSON library for C++11, providing JSON parsing and serializat...
jsoncpp 1.8.4 jsoncpp is an implementation of a JSON reader and writer in C++. JSON (JavaScr...
nlohmann-json 3.5.0-5 JSON for Modern C++
parson 2018-12-14 a lighweight json library written in C
picojson 1.3.0 A header-file-only, JSON parser serializer in C++.
rapidjson 1.1.0-3 A fast JSON parser/generator for C++ with both SAX/DOM style API <http://rapid...
sajson 2018-09-21 Lightweight, extremely high-performance JSON parser for C++11
yajl 2.1.0-1 Yet Another JSON Library
bạn google tên từng thư viện xem cái nào có cú pháp bạn thích nhất rồi chọn 1 thư viện mà xài thôi :V nlohmann-json
nghe nói nhanh, dễ install và cú pháp trong sáng :V
ví dụ:
#include <iostream>
#include "nlohmann/json.hpp"
#include <fstream>
int main()
{
std::ifstream ifs{"test.json"};
auto j = nlohmann::json::parse(ifs);
std::cout << j << "\n";
j["Ben"]["age"] = 19;
std::cout << j << "\n";
}
output:
{"Anna":{"age":18,"profession":"student"},"Ben":{"age":"nineteen","profession":"mechanic"}}
{"Anna":{"age":18,"profession":"student"},"Ben":{"age":19,"profession":"mechanic"}}