Skip to content

Commit

Permalink
Switches from MarshalIndent to json.Encoder with SetEscapeHTML(false);
Browse files Browse the repository at this point in the history
  • Loading branch information
tomnomnom committed Apr 19, 2018
1 parent 87d5fca commit ffb5f99
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,15 @@ func ungron(r io.Reader, w io.Writer, opts int) (int, error) {
}

// Marshal the output into JSON to display to the user
j, err := json.MarshalIndent(merged, "", " ")
out := &bytes.Buffer{}
enc := json.NewEncoder(out)
enc.SetIndent("", " ")
enc.SetEscapeHTML(false)
err = enc.Encode(merged)
if err != nil {
return exitJSONEncode, errors.Wrap(err, "failed to convert statements to JSON")
}
j := out.Bytes()

// If the output isn't monochrome, add color to the JSON
if opts&optMonochrome == 0 {
Expand Down

0 comments on commit ffb5f99

Please sign in to comment.