Then it is trivial to make the output indented (the second parameter of
json::OStream::OStream specifies the indentation).
Since this is JSON we're trying to emit, using the JSON stream makes sense to me. LGTM, but might be worth hanging on a bit to give others a chance to chime in.
I'm not sure how much weight my opinion carries here but I agree with removing the prints. I have never used these particular debug prints. When I want to inspect the output I usually just pipe it through python -m json.tool to format it.
The original idea was to have human-readable output on stderr and JSON output on stdout. But if this is no longer useful, I'm fine with removing it.
- json::OStream J(OS); + json::OStream J(OS, 2);
the JSON will be broken into multiple lines with an indentation of 2. I think that is quite readable, no need for stderr output.
I feel pretty OK approving this.
(Tradeoffs I'd contemplated and discarded was renaming OS rather than OS->J everywhere. I ended up liking the readability of J more. JS might be nice as well?)