bin | ||
doc/screens | ||
src | ||
.gitignore | ||
composer.json | ||
composer.lock | ||
LICENSE | ||
Makefile | ||
phpstan.neon | ||
README.md |
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, duplicate
- A minimum of dependencies
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. The recommended way of doing this is with the included
Makefile
and GNU Make:
$ git clone https://dev.noccylabs.info/jsonedit/jsonedit
$ cd jsonedit
$ make
$ mv 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
- Run
jsonedit
from your shell. - Press I to insert a new key. Select "Object" in the menu. Enter "services" and press enter.
- Select the newly created "services" key and press I to insert another object. Enter "nginx" and press enter.
- Select the newly created "nginx" key. Press i to insert a value. Enter "image" for key and "nginx" for value.
- Press I and select "Array". Enter "ports" and press enter.
- Select the "ports" key and press i. Enter "80:80" and press enter.
- Press ^W to save the file. Enter "compose.yaml" and press enter.
- Press ^X to exit.
You should now have a compose.yaml
file that spins up a completely useless
unconfigured nginx container.
Editing a document
- Run
jsonedit <filename>
from your shell, or runjsonedit
and press ^O to browse for a file to open. - Find the value you want to edit and press e.
- Enter the value usng valid JSON value encoding, for example
"1234"
for the string 1234, and1234
for the integer 1234. Unparsable JSON will be used as a verbatim string. - Make any additional edits, including using i and I to insert new keys and values, and D to delete values.
- Press ^W to save the file. Enter the filename to write and press enter.
- 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
- ^S - Open settings menu
Caveats
- YAML comments/formatting is not preserved - When reading YAML, comments are not preserved, and YAML formatting is not preserved when writing YAML.