Pretty Printing JSON Records

Let’s learn how to pretty print JSON records.

How to pretty print JSON records

This lesson illustrates how to pretty print JSON records, which means printing JSON records in a pleasant and readable format without knowing the format of the Go structure that holds the JSON records. As there exist two ways to read JSON records, individually and as a stream, there exist two ways to pretty print JSON data: as single JSON records and as a stream. Therefore, we are going to implement two separate functions named prettyPrint() and JSONstream(), respectively.

Coding example

The implementation of the prettyPrint() function is the following:

Get hands-on with 1200+ tech skills courses.