Comments (10)
This seems to have fixed the issue. Thanks for fixing it so swiftly!
from gron.
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!
from gron.
Hi @kseistrup! Thanks for raising an issue!
It looks like this is actually the default behaviour of Go's encoding/json
package (which is used only when the output is not colourised). I'll see about fixing this for you now
from gron.
@kseistrup this should be fixed in master now. Are you able to update with go get -u github.com/tomnomnom/gron
, or would you like me to upload a binary so you can test?
from gron.
I can go get
, so I'll try it right away…
from gron.
While the JSON itself is identical, the new code adds a blank line after the JSON whenever stdout
is not a TTY:
$ 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
}
}
$
from gron.
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"
]
from gron.
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
[
"&"
]
$
from gron.
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 ;)
from gron.
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
}
$
from gron.
Related Issues (20)
- --no-sort option is unstable HOT 5
- Ungron doesn't respect --no-sort option HOT 1
- Output format HOT 12
- more tollerance when parsing
- Remove this HOT 1
- Export functions? HOT 1
- asdf gron
- Colour - Support Highlighting when Ungronning from grep.
- Bash completions HOT 1
- gron will fail to link at runtime once OpenBSD removes syscall(2)
- Auto-provide command line completions
- panic with --values HOT 1
- `--no-sort` should apply on each line when using `-s`
- `gron URL` doesn't use the proxy defined in environment HOT 2
- Latest release
- ungron is slow and leaky HOT 7
- Binary builds broken?? HOT 4
- Add release for armv6l
- Special-case `new Array()` and `new Object`
- v0.7.1 does not report its own version HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gron.