Skip to main content

JMESPath Terminal

Project description

JMESPath, in your terminal!

https://cloud.githubusercontent.com/assets/368057/5158769/6546e58a-72fe-11e4-8ceb-ba866777983e.gif

Overview

JMESPath is an expression language for manipulating JSON documents. If you’ve never heard of JMESPath before, you write a JMESPath expression that when applied to an input JSON document will produces an output JSON document based on the expression you’ve provided.

You can check out the JMESPath site for more information.

One of the best ways to learn the JMESPath language is to experiment by creating your own JMESPath expressions. The JMESPath Terminal makes it easy to see the results of your JMESPath expressions immediately as you type.

Getting Started

You can install the JMESPath Terminal via pip:

$ pip install jmespath-terminal

There will then be a jpterm program you can run:

$ jpterm

With no arguments specified, a sample JSON document is used as input.

You can also specify an initial JSON document to use by specifying the JSON file as a positional argument:

$ jpterm /tmp/somejsondoc.json

You can also pipe an input JSON document into the jpterm command:

https://cloud.githubusercontent.com/assets/368057/5158770/6a6afb6e-72fe-11e4-8be3-893edf21920e.gif

Output

When the jpterm program exits (via F5 or Ctrl-c), jpterm may write content to stdout depending on the output mode. There are three output modes:

  • result - Whatever is in the “JMESPath result” pane (the right hand side) will be printed to stdout.

  • expression - Whatever is in the “JMESPath expression” pane is printed to stdout.

  • nothing - Nothing is written to stdout when exiting.

The default mode is “result”, which means that by default, whatever is in the result pane will be printed to stdout when jpterm exits. You can switch output modes using Ctrl-p, which will cycle through the three modes above. You can also specify what mode to use when starting the jpterm command using the -m/--output-mode command line option.

Keyboard Shortcuts

F5 or Ctrl + c
Quit the program.
Ctrl + p
Output mode toggle. Toggle between outputting the current result,
expression, or nothing. This is discussed in the “Output” section above.
Ctrl + ]
Clear the current expression.

Mouse Clicks

NOTE: These features are dependent on terminal support. (The Terminal.app included in Mac OS X does not support this, but iTerm2 does.)

One feature of the Urwid Python package (which jmespath-terminal is built on) is that mouse clicks are recognized. This allows you to click to switch focus on either the Input or Result window (and of course back to the Expression) and scroll it.

This can make it difficult to select text for copying/pasting. Many Linux terminals will allow you to select the text with a Shift + click/drag and copy it with Shift + Ctrl + c. In iTerm2 selections can be made with Opt/Alt + click/drag.

Working on JMESPath Terminal

If you like to work on jmespath-terminal to add new features, you can first create and activate a new virtual environment:

$ virtualenv venv
$ . venv/bin/activate

Then install the module:

$ pip install -e .

You’ll now be able to modify the jpterm.py module and see your changes reflected when you run the jpterm command.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jmespath-community-terminal-1.1.1.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file jmespath-community-terminal-1.1.1.tar.gz.

File metadata

  • Download URL: jmespath-community-terminal-1.1.1.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/67.4.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.10

File hashes

Hashes for jmespath-community-terminal-1.1.1.tar.gz
Algorithm Hash digest
SHA256 931fcb1a083272aa3628fff4ddb4aaf081c5869a4ce61337a2b03c859885938b
MD5 37f5cc87413c1277f2eb1dd451905c41
BLAKE2b-256 bcd66b2ed96a4f1b6d3f7b05cf51b2b07c9c0d20b7825dc0ed742229f67bf49d

See more details on using hashes here.

File details

Details for the file jmespath_community_terminal-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: jmespath_community_terminal-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/67.4.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.10

File hashes

Hashes for jmespath_community_terminal-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8403bf57c14d45a8d10a2b3900f30194409c721a6b1ec79ceb0bf64b11be55f3
MD5 3f381f87070b66a43f3d4ec105f0b8d2
BLAKE2b-256 1008979f20c6c73905251050ff13ace80b3a357c10c69b9fbfd216817b89b219

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page