package prettify import ( "encoding/json" "fmt" "github.com/TylerBrock/colorjson" ) // Print will beautify the output of func Print(body interface{}) { b, err := json.Marshal(body) var obj map[string]interface{} //json.Unmarshal([]byte(body), &obj) json.Unmarshal(b, &obj) // Make a custom formatter with indent set f := colorjson.NewFormatter() f.Indent = 2 // Marshall the Colorized JSON s, err := f.Marshal(obj) if err != nil { panic(err) } fmt.Println(string(s)) }