diff options
author | Keith Zantow <kzantow@gmail.com> | 2022-10-06 19:34:47 -0400 |
---|---|---|
committer | Keith Zantow <kzantow@gmail.com> | 2022-10-06 19:34:47 -0400 |
commit | 6fda8118533aec0a73ca431cb32c7ca951b58200 (patch) | |
tree | 7822903eb502060bbea9e618b33665c027c0d701 /json/writer.go | |
parent | 993e4915516e773859e9947e9fe815f08a25ed5a (diff) | |
download | spdx-tools-6fda8118533aec0a73ca431cb32c7ca951b58200.tar.gz |
chore: Add v2.3 data model and JSON support
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Diffstat (limited to 'json/writer.go')
-rw-r--r-- | json/writer.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/json/writer.go b/json/writer.go index bcc00a7..8f2b94d 100644 --- a/json/writer.go +++ b/json/writer.go @@ -4,6 +4,7 @@ package spdx_json import ( "encoding/json" + "github.com/spdx/tools-golang/spdx/v2_3" "io" "github.com/spdx/tools-golang/spdx/v2_2" @@ -23,3 +24,18 @@ func Save2_2(doc *v2_2.Document, w io.Writer) error { return nil } + +// Save2_3 takes an SPDX Document (version 2.2) and an io.Writer, and writes the document to the writer in JSON format. +func Save2_3(doc *v2_3.Document, w io.Writer) error { + buf, err := json.Marshal(doc) + if err != nil { + return err + } + + _, err = w.Write(buf) + if err != nil { + return err + } + + return nil +} |