c++ - rapidjson: working code for reading document from file? -
i need working c++ code reading document file using rapidjson: https://code.google.com/p/rapidjson/
in wiki it's yet undocumented, examples unserialize std::string, haven't deep knowledge of templates.
i serialized document text file , code wrote, doesn't compile:
#include "rapidjson/prettywriter.h" // stringify json #include "rapidjson/writer.h" // stringify json #include "rapidjson/filestream.h" // wrapper of c stream prettywriter output [...] std::ifstream myfile ("c:\\statdata.txt"); rapidjson::document document; document.parsestream<0>(myfile);
the compilation error state: error: 'document' not member of 'rapidjson'
i'm using qt 4.8.1 mingw , rapidjson v 0.1 (i try upgraded v 0.11 error remain)
the filestream
in @raanan's answer apparently deprecated. there's comment in source code says use filereadstream
instead.
#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);
Comments
Post a Comment