c++ jsoncpp 读取 json 文件
c++ jsoncpp Reading json file
我是 json 的新手,我试图从本教程站点读取我的 json 文件 https://en.wikibooks.org/wiki/JsonCpp
但是我收到一些链接器错误
1>------ 构建开始:项目:暮光冒险,配置:调试 Win32 ------ 1> 创建库 C:\Users\MinTeckNG\Desktop\TwilightAdventure\Debug\TwilightAdventure.lib 和对象 C:\Users\MinTeckNG\Desktop\TwilightAdventure\Debug\TwilightAdventure.exp 1>LoadMap.obj : 错误 LNK2019: 未解析的外部符号 "public: __thiscall Json::Reader::Reader(void)" (??0Reader@Json@@QAE@XZ) 在函数 "public: void __thiscall LoadMap::ReadJsonFileTest(void)" 中引用 (?ReadJsonFileTest@LoadingMap@@QAEXXZ) 1>C:\用户\MinTeckNG\桌面\暮光之城冒险\调试\暮光之城冒险.exe:致命错误LNK1120:1 个未解析的外部 =====
===== 构建:0 成功,1 失败,0 最新,0 跳过 ==========错误图片 LNK2019 未解析的外部符号
我的 JSON 文件要读取
{
"actors": [
{
"name": "Ground",
"pos": {
"x": 2592.0,
"y": 96.0
}
},
{
"name": "Grass",
"pos": {
"x": 2656.0,
"y": 96.0
}
}
}
我的代码
#include "LoadingMap.h"
#include <fstream>
LoadingMap::LoadingMap(void)
{
}
LoadingMap::~LoadingMap(void)
{
}
/*const char *LoadingMap::GetFileName(int stage, int difficulties)
{
char a = '0';
const char *ptr = &a;
return ptr;
}*/
/*void LoadingMap::ReadJsonFile(const char *filename)
{
}*/
void LoadingMap::ReadJsonFileTest()
{
std::ifstream ifs("1-1-0.json");
Json::Reader reader;
//Json::Value obj;
//reader.parse(ifs, obj);
//std::cout << "Object type: " << obj["name"].asString() << std::endl;
//const Json::Value& pos = obj["pos"];
//std::cout << " x: " << pos[0]["x"].asUInt();
//std::cout << " y: " << pos[1]["y"].asUInt();
}
我的头文件
#pragma once
#include <iostream>
#include <fstream>
#include <json/json.h>
class LoadingMap
{
public:
LoadingMap(void);
~LoadingMap(void);
//const char *GetFileName(int stage, int difficulties);
//void ReadJsonFile(const char *filename);
void ReadJsonFileTest();
private:
};
好吧,代码主要是什么都没有,还没有实现,我只是尝试按照教程进行修改.
改为RapidJSON而不是jsoncpp。 现在一切似乎都很好。
- 如何使用curlpp通过POST方法上传文件和json数据
- 如何在特定位置追加 json 文件
- 将 FlatBuffer 对象序列化为 JSON,而不使用其架构文件
- 如何在Visual C+++中从JSON文件中读取节点数据
- 如何将 json 数据附加到 Qt 中的现有 json 文件中
- 当前步骤:构建任务.json 文件
- 可以在JSON文件的帮助下在Qt中创建UI表单
- 将 cpprestsdk json 值对象写入文件
- 如何在 C++ 中使用提升属性树从 JSON 文件中读取对象数组
- 有没有办法从Makefile访问VS Code c_cpp_properties.json文件中的定义
- 保存json文件后如何返回文件路径
- 构造一个类似于JSON文件c++的字符串
- 使用 jsoncpp 读取 JSON 文件
- 在C++中打开 json 文件时遇到问题
- 使用 JSONCPP 将 JSON 数据增量写入文件
- Nlohmann 在不知道密钥的情况下解析 JSON 文件
- 如何使用 rapidjson 读取 json 文件并输出到 std::string?
- 比较 JSON::Value 变量中的数据,然后更新到文件
- 如何使用QJSONARRAY在QT5(C )中解析JSON文件(数组)
- 在 c++ 中读取配置文件 json 并没有停止