github.com/nextlinux/gosbom@v0.81.1-0.20230627115839-1ff50c281391/gosbom/formats/cyclonedxjson/encoder.go (about)

     1  package cyclonedxjson
     2  
     3  import (
     4  	"io"
     5  
     6  	"github.com/CycloneDX/cyclonedx-go"
     7  	"github.com/nextlinux/gosbom/gosbom/formats/common/cyclonedxhelpers"
     8  	"github.com/nextlinux/gosbom/gosbom/sbom"
     9  )
    10  
    11  func encoder(output io.Writer, s sbom.SBOM) error {
    12  	bom := cyclonedxhelpers.ToFormatModel(s)
    13  	enc := cyclonedx.NewBOMEncoder(output, cyclonedx.BOMFileFormatJSON)
    14  	enc.SetPretty(true)
    15  	enc.SetEscapeHTML(false)
    16  	err := enc.Encode(bom)
    17  	return err
    18  }