【发布时间】:2019-05-23 20:13:48
【问题描述】:
我正在尝试在我的 C++ 项目中使用 nlohmann json。从 github 下载压缩文件后,我提取了压缩文件。我将提取的文件夹重命名为 nlohmann_json 并将其复制到我的项目中。
github 文档说:
json.hpp 是 single_include/nlohmann 中的单个必需文件或在此处发布。你需要添加
#include <nlohmann/json.hpp>
// for convenience
using json = nlohmann::json;
所以在我的.cpp 文件中,我有以下几行:
#include "nlohmann_json/include/nlohmann/json.hpp"
using json = nlohmann::json;
但 Visual Studio 2015 IDE 以工具提示的形式显示以下消息:
命名空间 nlohmann 没有成员 json
仅输入 nlohmann:: 后,我会收到 json_pointer 的自动建议,但不是 json。
究竟出了什么问题?
【问题讨论】:
-
hm...根据 json.hpp,实际的类被命名为“basic_json”
-
@skeller,文档要求使用
using json = nlohmann::json;。我编辑了我的问题。 -
@IstiaqueAhmed 确定是
#include <nlohmann/json.hpp>而不是#include "nlohmann/json.hpp"? -
@πάνταῥεῖ,不清楚你说了什么。
-
根据文档,这似乎是正确的文件
标签: c++ nlohmann-json