From 3b5a2eeafe39f33ad03014a3060deb7426aa37d1 Mon Sep 17 00:00:00 2001 From: Mathieu Acthernoene Date: Thu, 15 Dec 2016 12:14:47 +0100 Subject: [PATCH] Add JSON utilities back --- encoder.go | 9 +++++++++ 1 file changed, 9 insertions(+) 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 {