1. Nlohmann JSON 库介绍
Nlohmann JSON 是一个用于 C++ 的现代 JSON 库,由 Niels Lohmann 开发。它以易用性和高性能著称,支持 C++11 及以上标准。
2. 编译和使用
2.1 获取库
可以通过以下方式获取库:
-
GitHub: nlohmann/json
-
包管理器: 如 vcpkg (vcpkg install nlohmann-json) 或 Conan (conan install nlohmann_json/3.10.5)
2.2 包含头文件
只需包含单个头文件即可使用:
#include <nlohmann/json.hpp>
2.3 使用示例
#include <iostream>
#include <nlohmann/json.hpp>