rapidjson
rapidjson copied to clipboard
add gzfilereadstream (zlib reader)
Add support for reading directly from gzipped file:
Example:
Input json:
{"a": 1, "x": 10, "y": [1,2,3], "m": {"c": "z"}}
Test:
#include <iostream>
#include <zlib.h>
#include "rapidjson/document.h"
#include "rapidjson/gzfilereadstream.h"
using namespace rapidjson;
using namespace std;
int main(int argc, char* argv[]) {
gzFile_s* fp = gzopen(argv[1], "r");
char readBuffer[65536];
GzFileReadStream is(fp, readBuffer, sizeof(readBuffer));
Document d;
d.ParseStream(is);
cout << d["m"].GetObject()["c"].GetString() << endl;
gzclose(fp);
return 0;
}
NOTE: compile with -lz: g++ -lz main.cpp
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.
Coverage increased (+0.0001%) to 99.739% when pulling fb45704458d03c601e157db4ddf8426549654333 on vindex10:feature/add_gzfilestream into 88bd956d66d348f478bceebfdadb8e26c6844695 on Tencent:master.
I think including this in the main library will add extra dependency to this project.
I suggest moving this to /contrib/gzip/. What do you think?
What is the status of this PR? The code seems to work fine, so we'd like to pick this change up, that's easier when it's merged :-) . Thanks in advance
I have trouble signing the agreement. The page doesn't open for me