Home

Awesome

This repository is no longer to develop.

tson

tson is JSON viewer and editor written in Go. This tool displays JSON as a tree and you can search and edit key or values.

Support OS

Installation

$ git clone https://github.com/skanehira/tson
$ cd tson && go install

Usage

# from file
$ tson < test.json

# from pipe
$ curl -X POST http://gorilla/likes/regist | tson

# from url(only can use http get mthod)
$ tson -url http://gorilla/likes/json

Use tson as a library in your application

You can use tson in your application as following.

package main

import (
	"fmt"

	tson "github.com/skanehira/tson/lib"
)

func main() {
	j := []byte(`{"name":"gorilla"}`)

	// tson.Edit([]byte) will return []byte, error
	res, err := tson.Edit(j)
	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Println(string(res))
}

Keybinding

JSON tree

keydescription
jmove down
kmove up
gmove to the top
Gmove to the bottom
ctrl-fpage up
ctrl-bpage down
hhide current node
Hcollaspe value nodes
lexpand current node
Lexpand all nodes
rread from file
ssave to file
aadd new node
Aadd new value
dclear children nodes
eedit json with $EDITOR
qquit tson
Enteredit node
/ or fsearch nodes
?show helps
spaceexpand/collaspe children nodes
ctrl-jmove to next parent node
ctrk-kmove to next previous node
ctrl-cquit tson

help

keydescription
jmove down
kmove up
gmove to the top
Gmove to the bottom
ctrl-fpage up
ctrl-bpage down
qclose help

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 valuejson type
gorillastring
10.5float
5int
true or falseboolean
nullnull
"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

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

Author

skanehira