Alex Goodman 5fb0235cfb
experiment with encoder/decoder for data encapsulation
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
2021-11-22 16:11:52 -05:00

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)
}