Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
kbrazil
searching Neon…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
15 ms
·
1.
▲
by
kbrazil
3y ago
There could be a major schema change that breaks the contract, but one of the nice things about JSON output is that it allows the creation of new fields without affecting downstream consumers. That is, if I have a CLI program that spits out
2.
▲
by
kbrazil
3y ago
`jc` supports plugins: https://github.com/kellyjonbrazil/jc#parser-plugins
3.
▲
by
kbrazil
3y ago
`jc` author here. I've been maintaining `jc` for nearly four years now. Most of the maintenance is choosing which new parsers to include. Old parsers don't seem to have too many problems (see the Github issues) and bugs are typica
4.
▲
by
kbrazil
3y ago
Also, `jc` automatically selects the correct /proc/file parser so you can just do `jc /proc/meminfo` or `cat /proc/meminfo | jc --proc` without specifying the actual proc parser (though you can do that if you w
5.
▲
by
kbrazil
3y ago
You can do it like this with Jello (I am the author): jello '[e.commit for e in _ if e.commit.author == "Tom Hudson"]' Jello let’s you use python syntax with dot notation without the stdin/stdout/json.
6.
▲
by
kbrazil
4y ago
Interesting - the proc-pid-parser actually parses that file name just fine: $ echo '2001 (bad) S 1 2 3 4 5) S 1888 2001 1888 34816 2001 4202496 428 0 0 0 0 0 0 0 20 0 1 0 75513 115900416 297 18446744073709551615 4194304 5100612 1
7.
▲
by
kbrazil
4y ago
It doesn't look like jc suffers from this bug since the regex match is greedy: % echo '2001 (my (file) with) S 1888 2001 1888 34816 2001 4202496 428 0 0 0 0 0 0 0 20 0 1 0 75513 115900416 297 18446744073709551615 4194304 510
8.
▲
by
kbrazil
4y ago
jc[0] supports proc files. Converts them to JSON or YAML. (I am the author) [0] https://kellyjonbrazil.github.io/jc/docs/parsers/proc
9.
▲
by
kbrazil
4y ago
Fortunately `jc`[0] does parse `/proc/<pid>/stat` correctly. I, of course, originally implemented it the naive/incorrect way until a contributor fixed it. :) $ cat /proc/2001/stat | jc --proc
10.
▲
by
kbrazil
4y ago
Both ways work: $ jc ifconfig lo0 $ ifconfig lo0 | jc --ifconfig
11.
▲
by
kbrazil
4y ago
Good news - `jc` supports JSONLines output for many commands and file-types, too!
12.
▲
by
kbrazil
4y ago
Also note that you are looking at plaintext output here. By default `jc` and other JSON filtering tools do syntax highlighting when outputting to the terminal so it's actually quite easy to read JSON these days.
13.
▲
by
kbrazil
4y ago
Hi - jc author here. Just a couple points: The casting to int/float is not done unless the underlying values are predictably documented to be numbers. There are rare cases where auto int/float conversions are done, but: 1) This is
14.
▲
by
kbrazil
4y ago
Feel free to open issues on GitHub if you would like to recommend parsers! Also, the latest version of jc supports parsing of /proc files, which may also help.
15.
▲
by
kbrazil
4y ago
Hi there! `jc` author here. Yes, it is a documented caveat[0] that the `C` or `en_US.UTF-8` locales should be used for best results. It's not unheard of for tools to require `C` locale for proper parsing: $ LC_ALL=C ls -l | jc --
16.
▲
by
kbrazil
4y ago
You can also run `jc -h --dig` to get the parser details that include the schema. Having true JSON Schema[0] is being considered, but on the back-burner due to the sheer number of parsers to build schemas for. Also, it is more difficult to
17.
▲
by
kbrazil
4y ago
`jc` is available today as a compiled binary with all dependencies self-contained. The binaries and OS package installers are available under the GitHub Releases: https://github.com/kellyjonbrazil/jc/releases This
18.
▲
by
kbrazil
4y ago
Hi there - author of `jc` here. I originally intended to have auto-detection but put that on the backburner to focus on creating parsers, especially after introducing the magic syntax. I did implement auto-detection for `/proc` file pa
19.
▲
by
kbrazil
4y ago
Hi there - `jc` author here. `jc` can also output in YAML format with the `-y` flag. It is fairly trivial to add other options in the future since `jc` just turns the text into objects which can be serialized to many different formats. For
20.
▲
by
kbrazil
4y ago
Hi there - I'm the author of `jc`. I also created `jello`[0], which works just like `jq` but uses python syntax. I find `jq` is great for many things but sometimes more complex operations are easier for me to grok in python. [0] https
21.
▲
by
kbrazil
4y ago
Similar in concept to jello[0] which works like jq but uses python syntax. [0] https://github.com/kellyjonbrazil/jello
22.
▲
by
kbrazil
5y ago
You could do something like this in pure python without the json loading boilerplate with jello[0]. An interactive TUI for jello called jellex[1} is also available. (I am the author) [0] https://github.com/kellyjonbrazil
23.
▲
by
kbrazil
5y ago
For those who are comfortable with python, I created Jello[0], which works like jq but uses python syntax. I also created Jellex[1], which is a TUI built on Jello to assist with building the python queries. Jello gives you the power of pyth
24.
▲
by
kbrazil
5y ago
What I was getting at is: cpu: 0.2 kw_read_s: 0.12 is describing a single 'object'. How do you describe an array or list of these objects? Something like: cpu: 0.2 kw_read_s: 0.12 cpu: 1.3 kw_read_s
25.
▲
by
kbrazil
5y ago
New parser contributions for JC are always welcome!
26.
▲
by
kbrazil
5y ago
Maybe not, but more often than not you really have an array of objects, and that's where JSON helps.
27.
▲
by
kbrazil
5y ago
Yep, in JC you can see the schema for any parser like so: $ jc -h --dig
28.
▲
by
kbrazil
5y ago
If you like python you might check out jello[0]. I basically wrote it to give you the power and simplicity of python without the boiler plate in a jq-like form-factor. Jello also allows you to use dot-notation instead of dict bracket notati
29.
▲
by
kbrazil
5y ago
Grep would not be able to do numeric comparison, would it?
30.
▲
by
kbrazil
5y ago
That’s why I created jello[0]. You get the power of python without the boilerplate so the experience is closer to jq with python syntax. [0] https://github.com/kellyjonbrazil/jello
More ›