Fork that fixes ctty error with the edit command. Just bump pty lib to v1.1.11
Go to file
2022-07-13 12:05:10 +02:00
.circleci add circleci and goreleaser yaml 2019-11-02 16:54:52 +09:00
gui Don't save filtered json tree #15 2019-12-02 22:57:16 +09:00
lib when use tson as a library don't print log 2019-11-22 15:11:12 +09:00
.goreleaser.yml add circleci and goreleaser yaml 2019-11-02 16:54:52 +09:00
go.mod fix edit command 2022-07-13 12:05:10 +02:00
go.sum fix edit command 2022-07-13 12:05:10 +02:00
LICENSE add license 2019-10-28 18:24:26 +09:00
main.go set tview tty to stdin when read json from stdin 2019-11-07 23:13:19 +09:00
README.md Update README.md 2022-01-18 09:21:37 +09:00
test.json add float test data 2019-10-30 20:32:17 +09:00

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

  • Mac
  • Linux

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

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 value 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
e edit json with $EDITOR
q quit tson
Enter edit node
/ or f search nodes
? show helps
space expand/collaspe children nodes
ctrl-j move to next parent node
ctrk-k move to next previous node
ctrl-c quit tson

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

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

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