Render a json to a string (minified)¶
Example on how to output your json to a string, minified.
If you want to transmit your json over the web it is generally advised to minify it to reduce its size.
C++:¶
Json json;
json.Parse(someJsonCode);
std::string renderedJson = json.Render(true);
std::cout << renderedJson << std::endl;
That's it.
Console output:¶
{"comments":[{"author":"Topper McNabb","message":"Shine yer armor for a copper.","timestamp":1178064000},{"author":"Ner'zhul","message":"I...have dreamed of you. I have had visions of death, and now you are here.","timestamp":1240617600},{"author":"Arthas Menethil","message":"This entire city must be purged.","timestamp":1021939200},{"author":"Terenas Menethil II","message":"At long last. No king rules forever, my son.","timestamp":1258156800}]}