---
title: jsonify
linktitle: jsonify
-description: Encodes a given object to JSON, returning pretty printed output.
+description: Encodes a given object to JSON.
godocref:
date: 2017-02-01
publishdate: 2017-02-01
return base64.StdEncoding.EncodeToString([]byte(conv)), nil
}
-// Jsonify encodes a given object to JSON, returning pretty printed output.
+// Jsonify encodes a given object to JSON.
func (ns *Namespace) Jsonify(v interface{}) (template.HTML, error) {
- b, err := json.MarshalIndent(v, "", " ")
+ b, err := json.Marshal(v)
if err != nil {
return "", err
}
v interface{}
expect interface{}
}{
- {[]string{"a", "b"}, template.HTML("[\n \"a\",\n \"b\"\n]")},
+ {[]string{"a", "b"}, template.HTML(`["a","b"]`)},
{tstNoStringer{}, template.HTML("{}")},
{nil, template.HTML("null")},
// errors
ns.AddMethodMapping(ctx.Jsonify,
[]string{"jsonify"},
[][2]string{
- {`{{ (slice "A" "B" "C") | jsonify }}`, "[\n \"A\",\n \"B\",\n \"C\"\n]"},
+ {`{{ (slice "A" "B" "C") | jsonify }}`, `["A","B","C"]`},
},
)