1
0
mirror of https://github.com/taigrr/yq synced 2025-01-18 04:53:17 -08:00

Pretty print json

This commit is contained in:
Mike Farah
2020-02-03 16:31:03 +11:00
parent b3598aaa43
commit 166f866f28
5 changed files with 49 additions and 30 deletions

View File

@@ -29,8 +29,11 @@ type jsonEncoder struct {
encoder *json.Encoder
}
func NewJsonEncoder(destination io.Writer) Encoder {
func NewJsonEncoder(destination io.Writer, prettyPrint bool) Encoder {
var encoder = json.NewEncoder(destination)
if prettyPrint {
encoder.SetIndent("", " ")
}
return &jsonEncoder{encoder}
}