lundi 27 février 2017

Minify output from rapidjson

I am using rapidjson to output some data for doing some statistic and plotting of a c++ programms algorithm like an internal runtime snapshots of the algorithm.

I output json like this:

string filename="output.json";
StringBuffer sb;
PrettyWriter<StringBuffer> writer(sb);
writer.StartArray();
for (std::vector<O_Class>::const_iterator netItr = O_Class_Array.begin();   netItr != O_Class_Array.end(); ++netItr)
    netItr->Serialize(writer);
writer.EndArray();

ofstream out;
out.open(filename);
out << sb.GetString() ;

As files become quite big (~100MiB) i'd like to output minified json, but I didn't find a documented way of doing so. With an external minifier I shrunk filesize from 100 to 18MB and like to have the same result as native in my application.

Any ideas?

Thanks for any suggestions!

Aucun commentaire:

Enregistrer un commentaire