I recently wrote a json pretty-printer for sequences of json objects in Golang. The file contains a sequence of json objects (not a json list) that look like:
{"foo":bar"}{"ham":"spam"}...
The goal was to load sequences of arbitrary json objects and pretty-print them using json.MarshalIndent. So I Decode()d the data into an interface{} variable and then MarshalIndent'ed it. This worked fine except that all the numbers are now floats, so upon re-encoding some numbers that started out like "123123123" ended looking like "1.23123123e+08".
I then discovered json.Indent, which could deal with this case if I just had a single json object, but afaict it cannot deal with a sequence of json objects (and I do not know where the end points of each json object are - I was relying on Decode() to determine this for me). For example, this:
var buf bytes.Buffer
err := json.Indent(&buf, []byte(`{"foo":"bar"}{"ham":"spam"}`), "", " ")
gives an error, which is understandable since the string is not a valid json object.
Any suggestions on how to achieve this?