Skip to content

encoding/json: Encoder adds trailing newlines #7767

@gopherbot

Description

@gopherbot

by opennota:

json.Encoder adds trailing newlines after values:
http://play.golang.org/p/skOwJv7qZR

This behaviour should be documented or removed.

I personally do not see why it should work so. 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')

But the reader will know that without the newline, because numbers will be followed by
',', ']', '}', or EOF, right?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions