This is a small utility that uses jp
underneath to query your JSON buffer and displays the result in a new buffer named *JMESPath Result*
.
Please refer jmespath repository to know more about the jp
command line utility.
- Open a
JSON
file. - Run the function using
M-X jmespath-query-and-show
. - Enter your JMESPath query and press enter.
- Run the function with universal-argument set,
C-u M-x jmespath-query-and-show
- Enter your JMESPath query and press enter.
- Enter the file you want to query on and press enter.
You can use jmespath-query-buffer
and jmespath-query-file
in yout program to run the query and get the result as string output.
Open a scratch buffer or open the below source code in org special edit.
{"employees":[
{"name":"Shyam", "email":"[email protected]"},
{"name":"Bob", "email":"[email protected]"},
{"name":"Jai", "email":"[email protected]"}
]}
Run the query @.employees[*].name
by typing M-X jmespath-query
to get an array of employee names.
The output would be something like this.
[
"Shyam",
"Bob",
"Jai"
]