1// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 2 3package spdx_json 4 5import ( 6 "encoding/json" 7 "github.com/spdx/tools-golang/spdx/v2_3" 8 "io" 9 10 "github.com/spdx/tools-golang/spdx/v2_2" 11) 12 13// Save2_2 takes an SPDX Document (version 2.2) and an io.Writer, and writes the document to the writer in JSON format. 14func Save2_2(doc *v2_2.Document, w io.Writer) error { 15 buf, err := json.Marshal(doc) 16 if err != nil { 17 return err 18 } 19 20 _, err = w.Write(buf) 21 if err != nil { 22 return err 23 } 24 25 return nil 26} 27 28// Save2_3 takes an SPDX Document (version 2.2) and an io.Writer, and writes the document to the writer in JSON format. 29func Save2_3(doc *v2_3.Document, w io.Writer) error { 30 buf, err := json.Marshal(doc) 31 if err != nil { 32 return err 33 } 34 35 _, err = w.Write(buf) 36 if err != nil { 37 return err 38 } 39 40 return nil 41} 42