github.com/kastenhq/syft@v0.0.0-20230821225854-0710af25cdbe/syft/formats/syftjson/encoder.go (about) 1 package syftjson 2 3 import ( 4 "encoding/json" 5 "io" 6 7 "github.com/kastenhq/syft/syft/sbom" 8 ) 9 10 func encoder(output io.Writer, s sbom.SBOM) error { 11 doc := ToFormatModel(s) 12 13 enc := json.NewEncoder(output) 14 // prevent > and < from being escaped in the payload 15 enc.SetEscapeHTML(false) 16 enc.SetIndent("", " ") 17 18 return enc.Encode(&doc) 19 }