json.go 248 B

123456789101112131415
  1. package report
  2. import (
  3. "encoding/json"
  4. "io"
  5. )
  6. func writeJson(findings []*Finding, w io.WriteCloser) error {
  7. if len(findings) == 0 {
  8. return nil
  9. }
  10. encoder := json.NewEncoder(w)
  11. encoder.SetIndent("", " ")
  12. return encoder.Encode(findings)
  13. }