mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 16:33:21 +01:00
24 lines
405 B
Go
24 lines
405 B
Go
package syftjson
|
|
|
|
import (
|
|
"encoding/json"
|
|
"io"
|
|
|
|
"github.com/anchore/syft/syft/sbom"
|
|
)
|
|
|
|
type encoder struct {
|
|
appConfig interface{}
|
|
}
|
|
|
|
func (e encoder) Encode(output io.Writer, s sbom.SBOM) error {
|
|
doc := ToFormatModel(s, e.appConfig)
|
|
|
|
enc := json.NewEncoder(output)
|
|
// prevent > and < from being escaped in the payload
|
|
enc.SetEscapeHTML(false)
|
|
enc.SetIndent("", " ")
|
|
|
|
return enc.Encode(&doc)
|
|
}
|