Comments (12)
Closely related, there could be an option also for removing the useless lines ending with "= {};" and "= [];". That would make it even more grepable!
from gron.
I would like to remove ending ";" from lines and also remove spaces before and after "=" so instead of this:
...
cat test.json | grep "json.message.chat.id" | cut -d"=" -f2
If you're going to pipe the output anyway, why not just run it through sed -e "s/ = /=/" -e "s/;$//"
to get the format you like?
from gron.
Closely related, there could be an option also for removing the useless lines ending with "= {};" and "= [];". That would make it even more grepable!
They're not useless. They may the output correct JSON.
from gron.
They're not useless. They may the output correct JSON.
Sure, but sometimes you don't care about that. The same option could remove the semicolons, these "empty" lines, and even the equal signs altogether (so that the output is, from the unix point of view, just two columns of NAME VALUE pairs). As @muzzol , often I also spend a lot of sed and awk just to remove this clutter before processing it further.
If this option is easy to add, it would be nice to have.
from gron.
Piling on, it would be nice to have a mode with guaranteed consistency for how keys are represented. That is, quoting all of them rather than on those that are not identifiers.
json = {};
-json.Host = "headers.jsontest.com";
+json["Host"] = "headers.jsontest.com";
json["User-Agent"] = "gron/0.1";
json["X-Cloud-Trace-Context"] = "6917a823919477919dbc1523584ba25d/11970839830843610056";
from gron.
quoting all of them
But wouldn't this make the output less greppable in general? I'd rather have all keys without quotes, regardless of whether they are identifiers or not.
from gron.
I'd rather have all keys without quotes, regardless of whether they are identifiers or not.
That would violate "The output of gron
is valid JavaScript", see https://tc39.es/ecma262/multipage/ecmascript-language-expressions.html#prod-MemberExpression and https://tc39.es/ecma262/multipage/ecmascript-language-lexical-grammar.html#sec-identifier-names-static-semantics-early-errors .
from gron.
That would violate "The output of
gron
is valid JavaScript"
Sure, and because of this reason the simplified output should not be the default behavior of gron. Still, there may be some value in providing a "super-greppable" uncluttered output for when you don't care that the output is valid javascript (e.g., inside a shell pipeline). For example, I'd like to have an output that looks just like this :
Host headers.jsontest.com
User-Agent gron/0.1
X-Cloud-Trace-Context 6917a823919477919dbc1523584ba25d/11970839830843610056
that is, a text file with two columns that can be directly processed by the standard unix utilities.
from gron.
Sure, and because of this reason the simplified output should not be the default behavior of gron. Still, there may be some value in providing a "super-greppable" uncluttered output for when you don't care that the output is valid javascript
exactly this.
creating simple bash scripts is one of the reasons I choose this tool, it's not really important if origin is a regulated standard or just a line of text.
from gron.
just to give some context, here's the help for smbclient utility:
smbclient --help
Usage: smbclient service <password>
-R, --name-resolve=NAME-RESOLVE-ORDER Use these name resolution services only
-M, --message=HOST Send message
-I, --ip-address=IP Use this IP to connect to
-E, --stderr Write messages to stderr instead of stdout
-L, --list=HOST Get a list of shares available on a host
-m, --max-protocol=LEVEL Set the max protocol level
-T, --tar=<c|x>IXFvgbNan Command line tar
-D, --directory=DIR Start from directory
-c, --command=STRING Execute semicolon separated commands
-b, --send-buffer=BYTES Changes the transmit/send buffer
-t, --timeout=SECONDS Changes the per-operation timeout
-p, --port=PORT Port to connect to
-g, --grepable Produce grepable output
-q, --quiet Suppress help message
-B, --browse Browse SMB servers using DNS
notice the '-g' option: -g, --grepable Produce grepable output
from gron.
What if a property name includes the delimiter sequence?
from gron.
What if a property name includes the delimiter sequence?
Then the output would be slightly ambiguous, but still easily grepable.
from gron.
Related Issues (20)
- --no-sort option is unstable HOT 5
- Ungron doesn't respect --no-sort option HOT 1
- 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`
- github client downloa
- Feature Request: Support for Ruby syntax HOT 4
- failed to form statements: invalid character 'ï' looking for beginning of value HOT 3
- 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.