Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jsoncpp write incrementally

Tags:

c++

jsoncpp

I have to log down what my application does into a json file. Is expected that the application goes on for weeks and so I want to write the json file incrementally.

For the moment I'm writing the json manually, but there is some log-reader application that is using Jsoncpp lib and should be nice to write the log down with Jsoncpp lib too.

But in the manual and in some examples I haven't found anything similar.. It is always something like:

Json::Value root;
// fill the json

ofstream mFile;
mFile.open(filename.c_str(), ios::trunc);
mFile << json_string;
mFile.close();

That is not what I want because it unnecessary fills the memory. I want to do it incrementally.. Some advice?

like image 839
nkint Avatar asked Aug 25 '26 14:08

nkint


1 Answers

I am a maintainer of jsoncpp. Unfortunately, it does not write incrementally. It does write into a stream without using extra memory, but that doesn't help you.

like image 162
cdunn2001 Avatar answered Aug 28 '26 04:08

cdunn2001



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!