11* counsel-jq
22
3+ ** Live queries against JSON and YAML data
4+
35[[https://melpa.org/#/counsel-jq][file:https://melpa.org/packages/counsel-jq-badge.svg]]
46
5- TL;DR: If you're a fan of [[https://stedolan.github.io/jq/][jq]] and you're using Emacs
7+ TL;DR: If you're a fan of [[https://stedolan.github.io/jq/][jq]] or [[https://github.com/mikefarah/yq][yq]] and you're using Emacs
68[[https://github.com/abo-abo/swiper][Ivy/Swiper/Counsel]], then this package is for you.
79
8- Longer version: If you are working with complex nested JSON
9- structures, you are probably familiar with [[https://stedolan.github.io/jq/][jq]] which is like sed for
10- JSON data and great at what it does. However, being a command-line
11- tool like sed, the feedback for writing queries and seeing their
12- results is a discrete process and not live.
10+ Longer version: If you are working with complex nested JSON (or YAML)
11+ structures, you are probably familiar with [[https://stedolan.github.io/jq/][jq]] (or [[https://github.com/mikefarah/yq][yq]]) which is like
12+ sed for JSON data and great at what it does. However, being a
13+ command-line tool like sed, the feedback for writing queries and
14+ seeing their results is a discrete process and not live.
1315
1416#+begin_quote
1517Cool. That might even be a feature that would draw in new Emacs users!
@@ -22,20 +24,27 @@ modern completion frameworks like [[https://github.com/abo-abo/swiper][Ivy]], th
2224inputs, as well.
2325
2426counsel-jq is a package with which you can quickly test queries and
25- traverse a complex JSON structure whilst having live feedback. Just
26- call =M-x counsel-jq= in a buffer containing JSON, then start writing
27- your =jq= query string and see the output appear live in the message
28- area. Whenever you're happy, hit =RET= and the results will be
29- displayed to you in the buffer =*jq-json*=.
27+ traverse a complex JSON and YAML structure whilst having live
28+ feedback. Just call =M-x counsel-jq= in a buffer containing JSON or
29+ YAML, then start writing your =jq= or =yq= query string and see the
30+ output appear live in the message area. Whenever you're happy, hit
31+ =RET= and the results will be displayed to you in the buffer
32+ =*jq-json*=.
3033
3134Demo:
3235
3336[[file:images/demo-counsel-jq.gif][./images/demo-counsel-jq.gif]]
3437
3538** Configuration
3639
37- By default, the resulting =*jq-json*= buffer will have the major mode
38- =js-mode=, but that can be customized with the
40+ To define whether you want to use =yq= over =jq= as processing tool,
41+ call =M-x customize= and set =counsel-jq-command= to =yq=.
42+
43+ In the same manner you can define the name of the results buffer by
44+ customizing the =counsel-jq-buffer= variable.
45+
46+ Lastly, by default, the results buffer =*jq-json*= buffer will have
47+ the major mode =js-mode=, but that can be customized with the
3948=counsel-jq-json-buffer-mode= variable if you prefer =json-mode=,
4049=rsjx-mode= or any other mode.
4150
0 commit comments