-
Notifications
You must be signed in to change notification settings - Fork 329
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
Please do not change output strings #43
Comments
Hi @kseistrup! Thanks for raising an issue! It looks like this is actually the default behaviour of Go's |
@kseistrup this should be fixed in master now. Are you able to update with |
I can |
This seems to have fixed the issue. Thanks for fixing it so swiftly! |
While the JSON itself is identical, the new code adds a blank line after the JSON whenever $ gron config.json | grep friends
json.friends = {};
json.friends.hops = 3;
$ gron config.json | grep friends | ungron
{
"friends": {
"hops": 3
}
}
$ gron config.json | grep friends | ungron | cat
{
"friends": {
"hops": 3
}
}
$ |
In case like me you were wondering what is different about the 2 examples, here is something minimal to illustrate the issue: $ echo 'json[0] = "&";' | ungron
[
"&"
]
$ echo 'json[0] = "&";' | ungron | cat
[
"\u0026"
] |
Thanks for the minimal example, @rjmunro. That issue has been solved, but the JSON outputs are still not identical: $ echo 'json[0]="&";' | ungron
[
"&"
]
$ echo 'json[0]="&";' | ungron | cat
[
"&"
]
$ |
Hey; thanks for reminding me about this! I'll see if I can get a fix in for it soon. Happy to accept PRs for it too ;) |
I managed to get a few minutes free to sort this. The changes are available in v0.6.0. Please let me know if you hit any more problems! |
For lists and single elements the indentation is different: $ echo 3 | gron | ungron
3
$ echo 3 | gron | ungron | cat
3
$ echo '[1,2,3]' | gron | ungron
[
1,
2,
3
]
$ echo '[1,2,3]' | gron | ungron | cat
[
1,
2,
3
] Mappings are not affected, though: $ echo '{"a":true,"b":false}' | gron | ungron
{
"a": true,
"b": false
}
$ echo '{"a":true,"b":false}' | gron | ungron | cat
{
"a": true,
"b": false
}
$ |
Please consider the following JSON:
Seemingly, I can
gron
andungron
this to achieve an identical output:However, if
stdout
is not a TTY, what you get is something entirely different:IMHO,
gron
should make identical output no matter what. Ideally,gron
shouldn't try to outsmart the user and start interpreting string values or displaying them differently (even if the meaning is the same). At least provide a commandline switch so that the original strings are preserved.Cheers.
The text was updated successfully, but these errors were encountered: