Comments (4)
Hi @dbabits!
I'm afraid this is by design. Gron's output is a subset of JavaScript - in the same way JSON is a subset of JavaScript (or at least it nearly is). A big reason for this is to ensure that the output is easily parseable by gron -u
/ gron --ungron
, and not surprising to people that are already familiar with JavaScript syntax.
-
isn't valid in a JavaScript identifier / variable name so it has to be quoted.
There's some discussion of a similar issue in issue #30. If you're after an output format that is less strict but more consistent, you might find the tool I wrote and linked to in a comment on that issue useful.
I know this probably isn't the response you're after, but I'm afraid I'm not prepared to change gron's output format at this stage. Thanks for raising the issue all the same!
from gron.
@tomnomnom,
Thank you for your response. But, why not quote always-wouldn't it address the issue while being valid JavaScript?
from gron.
@dbabits that's a good question. In hindsight I think that would probably be the right thing to do. I do think the non-quoted version is easier to read where it's possible to use it, but the simplicity gained by always using the quoted version would probably have been a worthwhile trade-off.
I'm not a fan of breaking changes, so I think it's just going to have to stay the way it is. Ah well; you live and learn :)
from gron.
@tomnomnom
Thanks Tom. I'm not a fan of breaking changes either, but it could be justified in this case.
Consider: gron is probably often used in a pipeline (that's the whole idea):
cat json | gron | parse
The parse part has to handle both cases shown above which makes it more complicated than necessary.
Worse, probably many people (judging from my own experience:) will only code the first case, only to see their application break when data changes to include some new character, maybe long time in the future.
In my experience, it was difficult to debug, because data just didn't make it downstream(pattern didn't match - no errors), and it wasn't noticed, and when it was - it took quite an effort to try to understand why and to replicate.
So, I would rate it as a bug.
At a minimum, I think we should document it. Fixing is even better:) (maybe with a switch for backward compatibility?)
Thanks!
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.
- could you create releases? HOT 6
- Pager? HOT 1
- Feature request HOT 3
- Inconsistency in ungron for invalid inputs HOT 1
- Add github topics? HOT 1
- `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.