2

Jsoncpp FastWriter method why last line append blank? It's for there an method Json::StreamWriterBuilder and indentation field. I how to use this method? for no lines.

Fixed please look answer.

Dont like code:

Json::Value root;
root["name"] = "Arda";

Json::FastWriter out;
std::cout << "'" << out.write(root) << "'" << std::endl;

// Result:
'{"name": "Arda"}
'
Arda Demir
  • 49
  • 8

2 Answers2

3

I now StreamWriterBuilder method using for nice result !

Json::StreamWriterBuilder wbuilder;
wbuilder["indentation"] = "";
std::cout << "'" << Json::writeString(wbuilder, root) << "'" << std::endl;
Arda Demir
  • 49
  • 8
0

FastWriter appends an additional line feed to each result. This can be really annoying.

Although FastWriter is now deprecated (and should be replaced with StreamWriterBuilder) you can omit this ending line by using omitEndingLineFeed()

Json::FastWriter writer;
writer.omitEndingLineFeed();
return writer.write(root);
Ben
  • 1,519
  • 23
  • 39