Logo

dev-resources.site

for different kinds of informations.

Using Jmespath in Emacs

Published at
2/7/2024
Categories
emacs
doom
jmespath
Author
schwiftycold
Categories
3 categories in total
emacs
open
doom
open
jmespath
open
Author
12 person written this
schwiftycold
open
Using Jmespath in Emacs

Introduction

When you have a small JSON file, it is quite easy to look for what you want. But querying a large JSON data is very troublesome.

This is where people use tools like Jmespath to filter and transform data into their liking. This post is about a small wrapper over jp CLI utility that you can use while working on JSON files in Emacs.

Installing JP

Linux

On Linux, you can install the utility by first downloding the binary and then installing it.

> sudo wget https://github.com/jmespath/jp/releases/latest/download/jp-linux-amd64 \
> -O /usr/local/bin/jp && sudo chmod +x /usr/local/bin/jp

Enter fullscreen mode Exit fullscreen mode

Mac

On Mac, you can install Jmespath CLI using brew.

> brew install jmespath/jmespath/jp

Enter fullscreen mode Exit fullscreen mode

Adding Jmespath recipe in Emacs

This is my first recipe that I published on MELPA.Here are the steps to install it in Doom using straight. You can use any package manager to install it using MELPA repository.

Doom Emacs

  1. On Doom, you can just mention the below recipe in your package.el.
> (package! jmespath)

Enter fullscreen mode Exit fullscreen mode
  1. Also, add the below line in your config.el.
> (use-package jmespath)

Enter fullscreen mode Exit fullscreen mode

Using Jmespath

There is an interactive function, jmespath-query-and-show that you can use to query the currently opened buffer or a file. To use it with current buffer, you can simply call this function and enter your query. The output will be shown on a new buffer with name JMESPath Result.

To use this with a different file, you can set the Universal Argument using C-u or SPC-u (using evil). Then you can enter the file to execute the query on.

Read more

To learn more about JMESPath, visit Jamespath page.

emacs Article's
30 articles in total
Favicon
Emacs 2024 Changes
Favicon
emacs error Failed to verify signature archive-contents.sig
Favicon
Mastering Parentheses in Emacs: Essential Commands
Favicon
C Development with GNU Emacs
Favicon
Mastering Golang Debugging in Emacs
Favicon
Emacs for Python and Poetry Using `basedpyright-langserver`
Favicon
Explorando org-babel en emacs
Favicon
(Game)Dev with Emacs - Because it's not Already Hard Enough Without it
Favicon
The Power of Tries, Data Structure Optimization in Emacs
Favicon
Creating an Emacs major mode - because why not?
Favicon
Learning to Like Neovim
Favicon
Emacs, a simple tour
Favicon
Learning Lisp
Favicon
Managing multiple terminals in Emacs
Favicon
Vim-style repeatable key bindings for navigating windows in Emacs
Favicon
Mermaid preview using xwidget browser
Favicon
Setting up Doom Emacs for Astro Development
Favicon
Moving to Emacs Tree Sitter Modes
Favicon
Mastering JSX Editing in Emacs with Tree-sitter
Favicon
Exploring Syntax Trees in Emacs with Tree-sitter
Favicon
Chinese Zodiac Time for Emacs
Favicon
Using Jmespath in Emacs
Favicon
From Doom to Vanilla Emacs
Favicon
Tell runtime/cgo to not thread warnings as errors
Favicon
Creating dynamic task runners for your npm scripts in Emacs
Favicon
5 ways to get text from an Emacs buffer
Favicon
Using age with org-journal
Favicon
Once again I wanted to have Emacs be my XML Notepad 2006
Favicon
Dia 9
Favicon
Emacs is More Like a Terminal Than an Editor

Featured ones: