Live data from Hacker News

Fx – Terminal JSON Viewer

fx.wtf

51–60 of 80 posts

Re: Fx – Terminal JSON Viewer

#52
post #15

Earlier quoted context omitted.

Not OP but echo '{"name": "world"}' | fx 'x => x.name' 'x => `Hello, ${x}!`' Is immediately grokkable compared to jq's syntax. I love jq, I think it's extremely powerful, but I have to load up the documentation in a side window every time I have use it.

Equivalent jq seems okay here: echo '{"name": "world"}' | jq '"Hello \(.name)"'

As someone who doesn't use jq, a number of questions immediately jump out at me. Why is the input string double qouted ('"input"')? What does the backslash annotate? At first it looks like an escape similar to regex, but the other bracket doesn't have it so it must mean something else? Etc. Of course I could look the answers up, but the point is I can't tell without looking it up. While the code is short it feels similar to Awk, if you know it it's trivial, if you don't know it it's hard to be sure what it does without trying it out.

Re: Fx – Terminal JSON Viewer

#53
Pretty cool! I actually wrote something VERY similar a couple of years ago: sless[1]. It's a tool for viewing json-based structured logs. Just like your tool, you can explore into a json object. The difference is, it expects the input to have many json objects, newline separated, and it shows few keys as a preview of the object, to make looking for something in the log easier. It's not quite complete but basic browsing works. It was mainly written to learn more about Urwid[2], a library similar to Curses.

1: https://github.com/dpedu2/sless

2: https://urwid.org/

Re: Fx – Terminal JSON Viewer

#56
post #2

Hey HN friends! I've taken `fx` back to the drawing board and completely rewritten it from the ground up. Excited to share what's new: 1. *Going Big*: `fx` now gracefully handles even the most massive JSON files. 2. *A New TUI Look*: Dive deep into your data with a revamped terminal interface—now with themes! 3. *Swift Navigation with Dig Fuzzy Search*: Feeling lost in JSON? Just type `.` and navigate with ease. 4. *…

Some feedback:

- Some indication of how far down you've scrolled would be useful for "situational awareness". Perhaps a percentage number in the status bar (like emacs/vim?)

- I miss not having the Home/End keys bound to the goto top/bottom actions

- The cursor behavior when pressing PageDn/PageUp throws me off.

Emacs when pressing PageDn: Cursor ends up at the top of the window.

Vim: Cursor stays at the current position.

notepad.exe: Cursor ends up in the middle of the window.

Fx: Cursor ends up at the bottom of the window.

- The . navigation is very neat with the tab completion. Probably stupid observation: If you remove the alphabet key shortcuts you wouldn't need the (non-discoverable) dot. :)

Re: Fx – Terminal JSON Viewer

#58
post #15

Earlier quoted context omitted.

Equivalent jq seems okay here: echo '{"name": "world"}' | jq '"Hello \(.name)"'

jq seems shorter but I don't see how it's more intuitive - ".name" is pretty basic jq syntax but how do I know \() is syntax for wrapping selectors within strings? I've used jq for many years and tbh I've never done string templating with it, so I would need to go digging in the docs. You can argue that's the case for any language, but it's the fundamental reason DSLs rarely capture the mainstream for on-the-fly util…

Maybe the person you replied to fixed a syntax error in an edit? The backticks are required, and are currently in their comment.

Re: Fx – Terminal JSON Viewer

#59

Earlier quoted context omitted.

Hello, Is there a commonly-used grammar for "json with comments and trailing commas" or does everyone just try to copy the jsonc from vscode?

It's basically https://json5.org/ CUE will happily take your JSON with comments and extra commas, or no commas too (lists still need them), most keys can be unquoted, and it's just a one-liner to get valid json or yaml from it

Jsonnet does too I believe. I wanted to like Cue but it only works with Go and it doesn't actually let you link the schemas you write from the "document" files, which means no automatic schema checking and no IDE support. Giving up two huge benefits of having a schema in the first place.

Re: Fx – Terminal JSON Viewer

#60
post #33
post #24

Earlier quoted context omitted.

Yes and both can be expressed in js and jq. Poinjt is what JS is known by much more peopel. As fx uses Node or Deno we for example can use lodash in fx: fx '_.groupBy("commit.author.name")' '_.mapValues(size)' '_.toPairs' '_.sortBy(1)' '_.reverse' '_.take(10)' '_.fromPairs' To do if in jq, it will take me much more time and extensive documentation reading.

What’s the original JSON? Happy to try and express this in jq

Looks like the GitHub API: https://docs.github.com/en/free-pro-team@latest/rest/commits...

I'm looking forward to your jq version. I love jq and use it all the time, but for anything of that complexity, I'd probably just use Python.

Post reply on HN