2
0
mirror of https://github.com/skanehira/tson synced 2024-11-15 12:13:04 +00:00
tson/README.md

127 lines
2.9 KiB
Markdown
Raw Normal View History

2019-10-28 09:23:49 +00:00
# tson
2019-11-01 11:14:16 +00:00
`tson` is JSON viewer and editor written in Go.
2019-10-31 03:20:55 +00:00
This tool displays JSON as a tree and you can search and edit key or values.
2019-11-02 13:06:39 +00:00
![](https://i.imgur.com/9Z6qOY4.gif)
2019-10-31 03:20:55 +00:00
2019-10-31 04:59:16 +00:00
## Support OS
- Mac
- Linux
## Installation
2019-10-31 03:20:55 +00:00
```sh
$ git clone https://github.com/skanehira/tson
$ cd tson && go install
2019-10-31 03:20:55 +00:00
```
## Usage
```sh
2019-11-02 07:49:34 +00:00
# from file
2019-10-31 03:20:55 +00:00
$ tson < test.json
2019-11-01 17:50:57 +00:00
2019-11-02 07:49:34 +00:00
# from pipe
$ curl -X POST http://gorilla/likes/regist | tson
# from url(only can use http get mthod)
2019-11-01 17:50:57 +00:00
$ tson -url http://gorilla/likes/json
2019-10-31 03:20:55 +00:00
```
## Keybinding
### JSON tree
2019-10-31 03:20:55 +00:00
2019-11-02 09:07:23 +00:00
| key | description |
|--------|----------------------|
| j | move down |
| k | move up |
| g | move to the top |
| G | move to the bottom |
| ctrl-f | page up |
| ctrl-b | page down |
| h | hide current node |
| H | collaspe all nodes |
| l | expand current node |
| L | expand all nodes |
| r | read from file |
| s | save to file |
| a | add new node |
| A | add new value |
| d | clear children nodes |
| Enter | edit node |
| / | search nodes |
2019-11-02 10:33:58 +00:00
| ? | show helps |
### help
| key | description |
|--------|--------------------|
| j | move down |
| k | move up |
| g | move to the top |
| G | move to the bottom |
| ctrl-f | page up |
| ctrl-b | page down |
| q | close help |
2019-10-31 03:20:55 +00:00
2019-11-02 07:49:34 +00:00
## About editing nodes
When editing a node value, the JSON value type is determined based on the value.
For example, after inputed `10.5` and saving the JSON to a file, it will be output as a float type `10.5`.
If the value sorround with `"`, it will be output as string type always.
The following is a list of conversion rules.
| input value | json type |
|--------------------|-----------|
| `gorilla` | string |
| `10.5` | float |
| `5` | int |
| `true` or `false` | boolean |
| `null` | null |
| `"10"` or `"true"` | string |
## About adding new node
You can use `a` to add new node with raw json string.
For expample, you have following tree.
```
{array} <- your cursor in there
├──a
├──b
└──c
```
If you input `{"name":"gorilla"}` and press add button,
then you will get new tree as following.
```
{array} <- your cursor in there
├──a
├──b
├──c
└──{object}
└──name
└──gorilla
```
2019-11-02 09:06:28 +00:00
Also, You can use `A` to add new value to current node.
For example, you have following tree.
```
{object} <- your cursor in there
└──name
└──gorilla
```
If you input `{"age": 26}` and press add button,
then you will get new tree as following.
```
{object} <- your cursor in there
├──name
│ └──gorilla
└──age
└──26
```
2019-10-31 03:20:55 +00:00
# Author
skanehira