-
Notifications
You must be signed in to change notification settings - Fork 328
Closed
Labels
Description
Please consider the following JSON:
{
"dependencies": {
"ssb-client": "http://localhost:8989/blobs/get/&EAaUpI+wrJM5/ly1RqZW0GAEF4PmCAmABBj7e6UIrL0=.sha256",
"ssb-mentions": "http://localhost:8989/blobs/get/&GjuxknqKwJqHznKueFNCyIh52v1woz5PB41vqmoHfyM=.sha256"
}
}Seemingly, I can gron and ungron this to achieve an identical output:
$ gron < test.json
json = {};
json.dependencies = {};
json.dependencies["ssb-client"] = "http://localhost:8989/blobs/get/&EAaUpI+wrJM5/ly1RqZW0GAEF4PmCAmABBj7e6UIrL0=.sha256";
json.dependencies["ssb-mentions"] = "http://localhost:8989/blobs/get/&GjuxknqKwJqHznKueFNCyIh52v1woz5PB41vqmoHfyM=.sha256";
$ gron < test.json | ungron
{
"dependencies": {
"ssb-client": "http://localhost:8989/blobs/get/&EAaUpI+wrJM5/ly1RqZW0GAEF4PmCAmABBj7e6UIrL0=.sha256",
"ssb-mentions": "http://localhost:8989/blobs/get/&GjuxknqKwJqHznKueFNCyIh52v1woz5PB41vqmoHfyM=.sha256"
}
}However, if stdout is not a TTY, what you get is something entirely different:
$ gron < test.json | ungron | cat # same thing happens if you redirect to a file
{
"dependencies": {
"ssb-client": "http://localhost:8989/blobs/get/\u0026EAaUpI+wrJM5/ly1RqZW0GAEF4PmCAmABBj7e6UIrL0=.sha256",
"ssb-mentions": "http://localhost:8989/blobs/get/\u0026GjuxknqKwJqHznKueFNCyIh52v1woz5PB41vqmoHfyM=.sha256"
}
}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.