diff --git a/encoder.go b/encoder.go index a45466d..d0c0cdd 100644 --- a/encoder.go +++ b/encoder.go @@ -2,6 +2,7 @@ package main import ( "bytes" + "encoding/json" "log" "os" "path/filepath" @@ -20,6 +21,14 @@ var ProtoHelpersFuncMap = template.FuncMap{ }) 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 {