Add JSON utilities back
This commit is contained in:
parent
e48d798d89
commit
3b5a2eeafe
@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"encoding/json"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -20,6 +21,14 @@ var ProtoHelpersFuncMap = template.FuncMap{
|
|||||||
}) string {
|
}) string {
|
||||||
return i.String()
|
return i.String()
|
||||||
},
|
},
|
||||||
|
"json": func(v interface{}) string {
|
||||||
|
a, _ := json.Marshal(v)
|
||||||
|
return string(a)
|
||||||
|
},
|
||||||
|
"prettyjson": func(v interface{}) string {
|
||||||
|
a, _ := json.MarshalIndent(v, "", " ")
|
||||||
|
return string(a)
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
type GenericTemplateBasedEncoder struct {
|
type GenericTemplateBasedEncoder struct {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user