Live data from Hacker News

Fx – Terminal JSON Viewer

fx.wtf

41–50 of 80 posts

Re: Fx – Terminal JSON Viewer

#41

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

Is the output ascii diagram only? Seems like a pretty different use case

No the output is a table object, you can apply other operations to it like sort, etc. the shell displays them in this ascii art way at the end but you can also write to files in various formats.

Re: Fx – Terminal JSON Viewer

#42
post #10

Having used https://jqlang.github.io/jq/ , wondering your pitch on advantages, alternative use cases for using fx?

Happy jq user as well. But is jq interactive?

ijq [1] is. I am using it almost every time I need to come up with a jq expression. However, it gets noticeably laggy with enormous JSONs.

[1]: https://sr.ht/~gpanders/ijq/

Re: Fx – Terminal JSON Viewer

#44
post #16

Earlier quoted context omitted.

wow nice, I'll give this a try. I've always used jq for viewing json, but it's the wrong tool for my use. I basically want to explore json interactively, not parse it specifically. So the workflow is to keep "jq"ing it, and modifying my jq query until I find what I'm looking for. Your tool looks like it allows interactive exploration.

You may be interested in an interactive jq tool like jiq or others: https://github.com/fiatjaf/awesome-jq (do a ctrl-f for "interactive" on this page).

That page doesn't include jless[1], which seems very similar to fx and will give you a jq selector for whatever node you're on

1: https://jless.io/

Re: Fx – Terminal JSON Viewer

#46
post #29

Earlier quoted context omitted.

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.

strace (on Linux) would have told you that without needing to user podman

Re: Fx – Terminal JSON Viewer

#47
> In fx, arguments are treated as JavaScript functions. Input data is passed sequentially through each provided function.

> echo '{"name": "world"}' | fx 'x => x.name' 'x => `Hello, ${x}!`'

Wow, that is so nice. Having to memorize JQ syntax is such a pain.

Re: Fx – Terminal JSON Viewer

#48
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 is YADSL though vs JS which is ubiquitous. Same reason most people can't use awk or sed.

Re: Fx – Terminal JSON Viewer

#50
post #16

Earlier quoted context omitted.

You may be interested in an interactive jq tool like jiq or others: https://github.com/fiatjaf/awesome-jq (do a ctrl-f for "interactive" on this page).

That page doesn't include jless[1], which seems very similar to fx and will give you a jq selector for whatever node you're on 1: https://jless.io/

This thread is a gem after gem, thank you!
Post reply on HN