github.com/noqcks/syft@v0.0.0-20230920222752-a9e2c4e288e5/syft/formats/syftjson/encoder.go (about)

     1  package syftjson
     2  
     3  import (
     4  	"encoding/json"
     5  	"io"
     6  
     7  	"github.com/anchore/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  }