Silly question:
I'm coming from toy languages such as JavaScript/Ruby/Python and when I want to output pretty JSON to the console most of these have some form of a pretty formatter that goes something like:

//javascript
console.log(JSON.stringify(jsonObj, null, 2));

// output
{
  "foo": "hello"
}

For the life of me, I cant figure out how "toPrettyJson" works. can someone give me a quick example?
here is how i thought its supposed to work

Json data = <some data>;
Json pretty;
toPrettyJson(pretty, data, 2);
writeln(pretty.toString());