Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proposal: encoding/json: add way to skip newlines while identation of simple arrays #19171

Closed
b-s-a opened this issue Feb 18, 2017 · 3 comments
Closed

Comments

@b-s-a
Copy link

b-s-a commented Feb 18, 2017

Currently json.Indent produces very huge output when used arrays of standard types (number, bool, string). So this output is not usable for human reading. Human never break line after each array item of int, for example.
So I suggest do not break them (only huge arrays may be created as some number of items per line).
Current indentation:
{
"array": [
1,
2,
3
]
}
Preffered (imho) indentation:
{
"array": [ 1, 2, 3 ]
}

@ALTree ALTree changed the title encoding/json add way to skip newlines while identation of simple arrays encoding/json: add way to skip newlines while identation of simple arrays Feb 18, 2017
@ALTree ALTree added the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Feb 18, 2017
@ALTree ALTree added this to the Go1.9 milestone Feb 18, 2017
@ALTree ALTree changed the title encoding/json: add way to skip newlines while identation of simple arrays proposal: encoding/json: add way to skip newlines while identation of simple arrays Feb 18, 2017
@ALTree ALTree added Proposal and removed NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. labels Feb 18, 2017
@ALTree ALTree modified the milestones: Proposal, Go1.9 Feb 18, 2017
@ALTree
Copy link
Member

ALTree commented Feb 18, 2017

I've turned this into a proposal since implementing this change will probably require adding a new function to the json package and/or changing Indent in a significant way.

@bradfitz
Copy link
Contributor

We're pretty much done adding to and modifying the JSON package at this point. And Indent has no place to add options anyway.

If there's a proposal, it would probably have to be about Encoder.

@rsc
Copy link
Contributor

rsc commented Feb 27, 2017

encoding/json isn't meant to be human-readable. It's nice that it is, but that's not a key part of the design of the package. It's easy enough for packages higher up the stack to do JSON reformatting, especially since they can assume or check (using encoding/json) that the input is valid JSON.

We're not going to go down the path of turning encoding/json into jsonfmt and then arguing about exactly how it should be formatted.

@rsc rsc closed this as completed Feb 27, 2017
@golang golang locked and limited conversation to collaborators Feb 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants