Live data from Hacker News

Fx – Terminal JSON Viewer

fx.wtf

31–40 of 80 posts

Re: Fx – Terminal JSON Viewer

#31
post #17

The other day, I found myself in need of visualising a tree of paths, like this: /one/two /one/three/four /one/three/five /six I ended up converting it to a JSON with a one-off Python script, and then using fx for the viewing. It worked very well! Thank you for the tool! (Incidentally, I’ve been writing my own viewer [0] to satisfy my original need more straightforwardly, but that’s still in very early stages.) [0]:…

As in filesystem paths? Are you aware of `tree`?

https://en.wikipedia.org/wiki/Tree_(command)

Re: Fx – Terminal JSON Viewer

#33
post #24
post #15

Earlier quoted context omitted.

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

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

Re: Fx – Terminal JSON Viewer

#34
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)"'

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 utilities. Leveraging existing knowledge of a more heavily used syntax really helps here. Look at awk for example - it's been around forever, and despite its power and ubiquity in OS installs, you'll still see sed in many many more bash scripts because it's leaning on widely used familiar syntax rather than a DSL.

That said - the fx example has "x => Hello, ${x}!" where I would expect "x => `Hello, ${x}!`", so that does indicate to me that fx has its own gotchas lurking - this example could just be contrived to look intuitive.

Re: Fx – Terminal JSON Viewer

#35
post #31
post #17

The other day, I found myself in need of visualising a tree of paths, like this: /one/two /one/three/four /one/three/five /six I ended up converting it to a JSON with a one-off Python script, and then using fx for the viewing. It worked very well! Thank you for the tool! (Incidentally, I’ve been writing my own viewer [0] to satisfy my original need more straightforwardly, but that’s still in very early stages.) [0]:…

As in filesystem paths? Are you aware of `tree`? https://en.wikipedia.org/wiki/Tree_(command)

Not necessarily filesystem paths (in my case, the paths correspond to RocksDB keys). And I’d like to be able to fold/unfold subtrees, search within node names, and call arbitrary commands for a given path in the tree, from within a TUI. So no, `tree` won’t cut it.

Re: Fx – Terminal JSON Viewer

#38
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. *…

how do you use the Built-in Functions? i tried them but it gives me error every time

Re: Fx – Terminal JSON Viewer

#39
post #29

Earlier quoted context omitted.

Where do you see npm/npx mentioned?

The project supports JS scripts as arguments to process the data: https://fx.wtf/getting-started#json-processing It's hard to tell from the docs if there is any JS involved if you just pipe JSON data to fx. I would hope not, since it mentions being written in Go for performance.

This is what I was wondering as well. Is there an interpreter built into the go binary? or is it using my node install under the hood?

Edit: Answered my own question. I installed it into a podman container with nothing else in it, and it printed this when trying to execute js:

    Node.js or Deno is required to run fx with reducers.

Re: Fx – Terminal JSON Viewer

#40

This could be done with nushell. https://www.nushell.sh/commands/docs/from_json.html

sure can do, if you already use that shell [1], but personally I like specific tools for specific jobs such as jq [2], fx, csvq [3] etc, there's value in decoupling shells from utils (modularity, speed, innovation etc).

[1] I don't but tempted to try, like its data-types concept

[2] https://jqlang.github.io/jq/

[3] https://github.com/mithrandie/csvq

Post reply on HN