c – rapidjson:从文件中读取文档的工作代码?

我需要一个工作的c代码,使用rapidjson: https://code.google.com/p/rapidjson/文件中读取文档

在wiki中它尚未记录,示例仅从std :: string反序列化,我对模板没有深入的了解.

我将我的文档序列化为一个文本文件,这是我写的代码,但事实并非如此
编译:

#include "rapidjson/prettywriter.h" // for stringify JSON
#include "rapidjson/writer.h"   // for stringify JSON
#include "rapidjson/filestream.h"   // wrapper of C stream for prettywriter as output
[...]
std::ifstream myfile ("c:\\statdata.txt");
rapidjson::Document document;
document.ParseStream<0>(myfile);

编译错误状态:错误:’Document’不是’rapidjson’的成员

我正在使用Qt 4.8.1和mingw以及rapidjson v 0.1(我已经尝试升级v 0.11,但错误仍然存​​在)

解决方法

@ Raanan的答案中的FileStream显然已被弃用.源代码中有一条评论说要使用FileReadStream.
#include <rapidjson/document.h>
#include <rapidjson/filereadstream.h>

using namespace rapidjson;

// ...

FILE* pFile = fopen(fileName.c_str(),"rb");
char buffer[65536];
FileReadStream is(pFile,buffer,sizeof(buffer));
Document document;
document.ParseStream<0,UTF8<>,FileReadStream>(is);

相关文章

本程序的编译和运行环境如下(如果有运行方面的问题欢迎在评...
水了一学期的院选修,万万没想到期末考试还有比较硬核的编程...
补充一下,先前文章末尾给出的下载链接的完整代码含有部分C&...
思路如标题所说采用模N取余法,难点是这个除法过程如何实现。...
本篇博客有更新!!!更新后效果图如下: 文章末尾的完整代码...
刚开始学习模块化程序设计时,估计大家都被形参和实参搞迷糊...