TL;DR: If you’re a fan of jq and you’re using Emacs Ivy/Swiper/Counsel, then this package is for you.
Longer version: If you are working with complex nested JSON structures, you are probably familiar with jq which is like sed for JSON data and great at what it does. However, being a command-line tool like sed, the feedback for writing queries and seeing their results is a discrete process and not live.
Cool. That might even be a feature that would draw in new Emacs users!
(alphapapa during the melpa submission)
When working with Emacs, we are used to good auto-completion and live feedback. Formerly, this was mostly done with static input, but with modern completion frameworks like Ivy, this can be done with dynamic inputs, as well.
counsel-jq is a package with which you can quickly test queries and
traverse a complex JSON structure whilst having live feedback. Just
call M-x counsel-jq
in a buffer containing JSON, then start writing
your jq
query string and see the output appear live in the message
area. Whenever you’re happy, hit RET
and the results will be
displayed to you in the buffer *jq-json*
.
Demo:
By default, the resulting *jq-json*
buffer will have the major mode
js-mode
, but that can be customized with the
counsel-jq-json-buffer-mode
variable if you prefer json-mode
,
rsjx-mode
or any other mode.
On [2020-11-29 Sun], Zen Monk Alain M. Lafon (@munen) gave a talk at
EmacsConf 2020 introducing counsel-jq
. There’s a video recording
with explanations and demos behind this complementary blog post:
https://200ok.ch/posts/2020-11-30_emacsconf_traverse_complex_json_structures_with_live_feedback_with_counseljq.html