What does it matter? It is still valid JSON, right?
http://play.golang.org/p/skOwJv7qZR
Any reason for this? Can this behaviour be changed by configuring the encoder? It is kind of unexpected to me. The encoding/json documentation does not mention it also.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
What does it matter? It is still valid JSON, right?
It's not configurable, AFAICT. From https://code.google.com/p/go/source/browse/src/pkg/encoding/json/stream.go#165// Terminate each value with a newline.// This makes the output look a little nicer// when debugging, and some kind of space// is required if the encoded value was a number,// so that the reader knows there aren't more// digits coming.e.WriteByte('\n')
The decoder handles streams of JSON values. See http://godoc.org/encoding/json#example-Decoder. The decoder requires a whitespace separator between a number and the JSON value that follows it. The encoder adds whitespace to accommodate the decoder.
The \n are not necessary for that.