Quickly jump to a nested key in a json buffer
You can just put `jjumper.el` somewhere in your load-path and eval the file. You can also use use-package with straight:
(use-package jjumper
:straight (jjumper :type git :host github :repo "flocks/jjumper")
:config
(define-key json-mode-map (kbd "C-c C-j") 'jjumper-jump-key))
The most common usecase, is to bind jjumper-jump-key to some convenience keychord in json-mode-map
(define-key json-mode-map (kbd "C-c C-j") 'jjumper-jump-key)
Since it’s using native completion system (completing-read), you can leverage embark for copying the path, or inserting somewhere.
I personnaly use it in a frontend application, where all translations keys are stored in a single json file. I can quickly search and insert a path in my code with the following snippet:
(defun ft-insert-translation-key ()
"Insert a translation key"
(interactive)
(let ((key (with-current-buffer
(find-file-noselect "~/project/path/to/translation.json")
(jjumper--prompt (jjumper--get-json-in-buffer)))))
(insert key)))
- Potentially handle different configuration format like YAML