News for hackers. Stuff that matters.
Re:Jqp – A TUI playground for exploring jq by pawelduda on Tuesday September 20, 2022 @06:03AM (#32909793)
When I am hacking something relatively simple together, I tend to do:

echo '' | fzf --preview 'jq {q} < filename.json'

This approach can be generalized to other tools, to some extent: https://github.com/pawelduda/fzf-live-repl

Re:Jqp – A TUI playground for exploring jq by AviationAtom on Tuesday September 20, 2022 @07:11AM (#32910198)
You kind of blew my mind with this simple concept. Going to see if I can incorporate it in my #kitbag
Re:Jqp – A TUI playground for exploring jq by ngorstein on Tuesday September 20, 2022 @07:18AM (#32910256)
Oh woah, love this. Thanks for sharing. Will definitely be giving it a try.
Re:Jqp – A TUI playground for exploring jq by anjanb on Tuesday September 20, 2022 @11:14AM (#32912833)
can you explain what exactly is happening here
Re:Jqp – A TUI playground for exploring jq by corney91 on Tuesday September 20, 2022 @01:35PM (#32915067)
fzf is an interactive tool for fuzzy-finding and will take input from stdin. For example, `ls | fzf` will allow you to search through a list of files in your working directory. It also has an optional preview pane that can be used to show the output of a command.

In this case, the empty string is provided as input because we're not interested in selecting options. You can then type your jq filter in fzf's query box and the command will run against filename.json in the preview pane on every kepress (the {q} is your currently typed query).

Re:Jqp – A TUI playground for exploring jq by sadjad on Monday September 19, 2022 @07:52PM (#32905763)
Very nice! For something quick and dirty (and `apt-get install`able), I usually use jq+fzf like this: https://gist.github.com/reegnz/b9e40993d410b75c2d866441add2c...
Re:Jqp – A TUI playground for exploring jq by snidane on Monday September 19, 2022 @08:06PM (#32905877)
Another useful json explorer TUI - jless.

https://jless.io/

Re:Jqp – A TUI playground for exploring jq by medv on Tuesday September 20, 2022 @05:29AM (#32909558)
Re:Jqp – A TUI playground for exploring jq by HellsMaddy on Monday September 19, 2022 @07:54PM (#32905775)
This is awesome!

I sometimes use jiq for this purpose, but I don't like that it tries to evaluate the query as you type, pressing enter exits the interactive session, and that you can't see the source and output at the same time. Jid has similar issues.

Jqp seems to solve all of these problems, plus it has syntax highlighting. I'm going to use this tool all the time.

Re:Jqp – A TUI playground for exploring jq by TakeBlaster16 on Monday September 19, 2022 @08:40PM (#32906146)
I've played with jid in jiq and IIRC they were very slow with large inputs since they re-parse the JSON blob every time the query changes. I wonder if this solves that problem--I'll bookmark it and find out next time I need to wrangle some JSON!
Re:Jqp – A TUI playground for exploring jq by ngorstein on Monday September 19, 2022 @08:44PM (#32906188)
wow, thanks so much for the kind words! Didn't think people would see this, let alone for it to show up on Hacker News haha. Hope you get a lot of use out of it!
Re:Jqp – A TUI playground for exploring jq by HellsMaddy on Monday September 19, 2022 @08:50PM (#32906230)
A feature that would be cool:

I often write some pretty complex jq queries. Once a query starts getting complex, I like to spread it over multiple lines for better readability. It would be cool if Jqp would let me insert newlines by pressing Shift+Enter.

Re:Jqp – A TUI playground for exploring jq by ngorstein on Monday September 19, 2022 @08:57PM (#32906290)
Yeah for sure! Initially I had tried to do something like this, hit a roadblock and just went with the 1 line input in order to get a v1 out. Definitely something I'd consider as I continue to iterate on it.
Re:Jqp – A TUI playground for exploring jq by flurie on Monday September 19, 2022 @08:29PM (#32906061)
I had fun writing a tree-sitter grammar[1] for jq, mostly based on the gojq parser. I realized it was probably in pretty good shape when a snippet that I thought was valid had a syntax error, which tree-sitter was happy to confirm. jq is a lot of fun to write and think with, and the stdlib is good but quirky. It would really benefit from some more libraries, so it's great to see tools to facilitate writing in it!

[1] https://github.com/flurie/tree-sitter-jq

Re:Jqp – A TUI playground for exploring jq by tambourine_man on Monday September 19, 2022 @11:27PM (#32907313)
I’m loving this resurgence of TUI apps. Only now the quality and cross compatibility is much better than in the 90’s.

Keep ‘em coming.

Re:Jqp – A TUI playground for exploring jq by noxvilleza on Monday September 19, 2022 @08:57PM (#32906291)
What would be really awesome (although likely means ripping apart jq) would be some intermediate query caching. I often browse through large-ish (~1-2GB) JSON files and do something similar to the example animation in that I repeatedly filter and look for something. It would be awesome if it were smart enough to reasonable cache "filter A" when later reasoning about "filter A and filter B".

Still really great as-is, will definitely use it.

Re:Jqp – A TUI playground for exploring jq by saulpw on Tuesday September 20, 2022 @03:07AM (#32908614)
Have you tried VisiData for this?
Re:Jqp – A TUI playground for exploring jq by noxvilleza on Wednesday September 21, 2022 @08:55PM (#32933599)
I have not, but I will investigate - cheers!
Re:Jqp – A TUI playground for exploring jq by Fnoord on Tuesday September 20, 2022 @06:21AM (#32909896)
I use ijq [1], saves me a lot of time.

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

Re:Jqp – A TUI playground for exploring jq by wseqyrku on Tuesday September 20, 2022 @11:36AM (#32913199)
Please include scoop installation for your tool. Sincerely, a lazy user on the Internet.
Re:Jqp – A TUI playground for exploring jq by AviationAtom on Tuesday September 20, 2022 @07:11AM (#32910203)
TUI = Training user environment?
Re:Jqp – A TUI playground for exploring jq by almog on Tuesday September 20, 2022 @07:16AM (#32910238)
TUI = Terminal User Interface
Re:Jqp – A TUI playground for exploring jq by John23832 on Tuesday September 20, 2022 @05:17AM (#32909447)
Wow cool.

This really makes me want TUIs for many other clis.

Re:Jqp – A TUI playground for exploring jq by togaen on Monday September 19, 2022 @09:18PM (#32906456)
I don’t know what any of those words mean.
Re:Jqp – A TUI playground for exploring jq by martyvis on Monday September 19, 2022 @10:35PM (#32907008)
jq is a tool that can query (search/extract/format) JSON (JavaScript readable data files).

I figured from the README that TUI probably stands for Text User Interface as it seems to support keystrokes in a way that an editor like Vi or Emacs work in a terminal (yeah I hadn't of it either, but I guess it is a retro acronym from GUI which is more well known)

Re:Jqp – A TUI playground for exploring jq by ZeroGravitas on Tuesday September 20, 2022 @02:58PM (#32916270)
And 'playground' often refers to interactive code environments, like this one for trying out tree-sitter parsing:

https://tree-sitter.github.io/tree-sitter/playground

Re:Jqp – A TUI playground for exploring jq by opan on Tuesday September 20, 2022 @02:24AM (#32908352)
TUI is anything sorta graphical and interactive in a terminal. Often but not always ncurses stuff.