ColorJSON: The Fast Color JSON Marshaller for Go
What is this?
This package is based heavily on hokaccha/go-prettyjson but has some noticible differences:
ColorJSON was built in order to produce fast beautiful colorized JSON output for Saw.
Installation
go get -u github.com/TylerBrock/colorjson
Usage
Setup
import "github.com/TylerBrock/colorjson"
str := `{
"str": "foo",
"num": 100,
"bool": false,
"null": null,
"array": ["foo", "bar", "baz"],
"obj": { "a": 1, "b": 2 }
}`
var obj map[string]interface{}
json.Unmarshal([]byte(str), &obj)
Vanilla Usage
s, _ := colorjson.Marshal(obj)
fmt.Println(string(s))
Customization (Custom Indent)
f := colorjson.NewFormatter()
f.Indent = 2
s, _ := f.Marshal(v)
fmt.Println(string(s))