How can I pretty-print JSON using Go?
By pretty-print, I assume you mean indented, like so { “data”: 1234 } rather than {“data”:1234} The easiest way to do this is with MarshalIndent, which will let you specify how you would like it indented via the indent argument. Thus, json.MarshalIndent(data, “”, ” “) will pretty-print using four spaces for indentation.