Skip to content

Render a json to a string (pretty print)


Example on how to output your json to a string.

C++:
Json json;
json.Parse(someJsonCode);


std::string renderedJson = json.Render();

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
        },
    ]
}