The delightful JSON and YAML editor for terminal junkies
Go to file
2024-10-05 16:34:49 +02:00
bin Rename to jsonedit 2024-10-01 23:02:51 +02:00
doc/screens Added screenshots 2024-10-04 12:46:45 +02:00
src Add makefile, cli options 2024-10-05 16:34:49 +02:00
.gitignore Add save to json/yaml (ctrl-w) 2024-10-01 21:40:13 +02:00
composer.json Refactor namespace, context sensitive info bar 2024-10-02 01:15:22 +02:00
composer.lock Initial commit 2024-10-01 18:46:03 +02:00
LICENSE Updat help, add license 2024-10-02 01:46:23 +02:00
Makefile Add makefile, cli options 2024-10-05 16:34:49 +02:00
README.md Editor fixes, code cleanup, bool colors, open dialog 2024-10-05 14:57:51 +02:00

JSONEdit

This is an editor for JSON files, that also supports YAML.

Warning

This software is still very much beta. That means there will be bugs. Please report them, and don't go doing stupid stuff like editing your live configuration files in place.

Features

  • Interactive terminal TUI application
  • Makes use of Unicode glyphs in 16 magnificent colors!
  • Handles array, objects and values
  • Folding of array and object keys
  • Core edit operations: insert, edit, delete
  • A minimum of dependencies
  • ~300KB executable PHAR

screenshot

Installing

The recommended way to install and run JSONEdit is by grabbing the PHAR from the latest release:

You can also clone the respository and use Box to build the .phar yourself:

$ git clone https://dev.noccylabs.info/noccy/jsonedit
$ cd jsonedit
$ composer install
$ box compile
$ mv bin/jsonedit.phar ~/bin/jsonedit

Using

JSONEdit is controlled using hotkeys. The essential keys are always displayed at the bottom of the screen. Press h for the help, which lists all available keys.

Creating a document from scratch

  1. Run jsonedit from your shell.
  2. Press I to insert a new key. Select "Object" in the menu. Enter "services" and press enter.
  3. Select the newly created "services" key and press I to insert another object. Enter "nginx" and press enter.
  4. Select the newly created "nginx" key. Press i to insert a value. Enter "image" for key and "nginx" for value.
  5. Press I and select "Array". Enter "ports" and press enter.
  6. Select the "ports" key and press i. Enter "80:80" and press enter.
  7. Press ^W to save the file. Enter "compose.yaml" and press enter.
  8. Press ^X to exit.

You should now have a compose.yaml file that spins up a completely useless unconfigured nginx container.

Editing a document

  1. Run jsonedit <filename> from your shell.
  2. Find the value you want to edit and press e.
  3. Enter the value usng valid JSON value encoding, for example "1234" for the string 1234, and 1234 for the integer 1234. Unparsable JSON will be used as a verbatim string.
  4. Make any additional edits, including using i and I to insert new keys and values, and D to delete values.
  5. Press ^W to save the file. Enter the filename to write and press enter.
  6. Press ^X to exit.

Folding

To fold and unfold keys, use the following keys:

  • + - Toggle folding of current key
  • - - Collapse all nodes but the first
  • - Collapse current key, or go to parent if a value or already collapsed
  • - Expand current key

Customizing JSONEdit

Use the following keys to customize the appearance of JSONEdit. The settings will be persisted for the next session if the directory ~/.config/jsonedit exists.

  • g - Toggle indentation guides
  • t - Toggle tail line guide
  • b - Toggle icons before keys
  • c - Toggle compact mode

Caveats

  • YAML comments/formatting is not preserved - When reading YAML, comments are not preserved, and YAML formatting is not preserved when writing YAML.