aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrandon Lum <lumjjb@gmail.com>2023-01-04 16:25:27 +0800
committerGitHub <noreply@github.com>2023-01-04 16:25:27 +0800
commitd6f58551be3f8268f8dca718e501de24895fa5b2 (patch)
treea17b8ba7daa907224c8b87a0891e2822b1c17812
parent7782317b3e7e06728ab21e196003a437bb4711c3 (diff)
parent6fe9d226281a9ea9947f44aa6e03fe9c589a8a42 (diff)
downloadspdx-tools-d6f58551be3f8268f8dca718e501de24895fa5b2.tar.gz
Merge pull request #174 from jedevc/json-tags
Ensure consistency between JSON struct tags across different SPDX versions
-rw-r--r--spdx/v2_1/creation_info.go2
-rw-r--r--spdx/v2_1/document.go14
-rw-r--r--spdx/v2_1/file.go2
-rw-r--r--spdx/v2_1/package.go4
-rw-r--r--spdx/v2_2/creation_info.go2
-rw-r--r--spdx/v2_2/document.go14
-rw-r--r--spdx/v2_2/package.go12
-rw-r--r--spdx/v2_3/creation_info.go2
-rw-r--r--spdx/v2_3/package.go2
9 files changed, 27 insertions, 27 deletions
diff --git a/spdx/v2_1/creation_info.go b/spdx/v2_1/creation_info.go
index f4c4f41..0e1bd87 100644
--- a/spdx/v2_1/creation_info.go
+++ b/spdx/v2_1/creation_info.go
@@ -22,5 +22,5 @@ type CreationInfo struct {
// 2.10: Creator Comment
// Cardinality: optional, one
- CreatorComment string `json:"comment"`
+ CreatorComment string `json:"comment,omitempty"`
}
diff --git a/spdx/v2_1/document.go b/spdx/v2_1/document.go
index 9721463..81738ff 100644
--- a/spdx/v2_1/document.go
+++ b/spdx/v2_1/document.go
@@ -53,13 +53,13 @@ type Document struct {
DocumentComment string `json:"comment,omitempty"`
CreationInfo *CreationInfo `json:"creationInfo"`
- Packages []*Package `json:"packages"`
- Files []*File `json:"files"`
- OtherLicenses []*OtherLicense `json:"hasExtractedLicensingInfos"`
- Relationships []*Relationship `json:"relationships"`
- Annotations []*Annotation `json:"annotations"`
- Snippets []Snippet `json:"snippets"`
+ Packages []*Package `json:"packages,omitempty"`
+ Files []*File `json:"files,omitempty"`
+ OtherLicenses []*OtherLicense `json:"hasExtractedLicensingInfos,omitempty"`
+ Relationships []*Relationship `json:"relationships,omitempty"`
+ Annotations []*Annotation `json:"annotations,omitempty"`
+ Snippets []Snippet `json:"snippets,omitempty"`
// DEPRECATED in version 2.0 of spec
- Reviews []*Review
+ Reviews []*Review `json:"-"`
}
diff --git a/spdx/v2_1/file.go b/spdx/v2_1/file.go
index ffdec94..2373887 100644
--- a/spdx/v2_1/file.go
+++ b/spdx/v2_1/file.go
@@ -66,7 +66,7 @@ type File struct {
// defined here -- so this should just be an ElementID.
Snippets map[common.ElementID]*Snippet `json:"-"`
- Annotations []Annotation `json:"annotations"`
+ Annotations []Annotation `json:"annotations,omitempty"`
}
// ArtifactOfProject is a DEPRECATED collection of data regarding
diff --git a/spdx/v2_1/package.go b/spdx/v2_1/package.go
index 4bf5636..6b0d7a5 100644
--- a/spdx/v2_1/package.go
+++ b/spdx/v2_1/package.go
@@ -95,7 +95,7 @@ type Package struct {
PackageExternalReferences []*PackageExternalReference `json:"externalRefs,omitempty"`
// Files contained in this Package
- Files []*File
+ Files []*File `json:"files,omitempty"`
Annotations []Annotation `json:"annotations,omitempty"`
}
@@ -116,5 +116,5 @@ type PackageExternalReference struct {
// 3.22: Package External Reference Comment
// Cardinality: conditional (optional, one) for each External Reference
- ExternalRefComment string `json:"comment"`
+ ExternalRefComment string `json:"comment,omitempty"`
}
diff --git a/spdx/v2_2/creation_info.go b/spdx/v2_2/creation_info.go
index d56d9a5..70e611f 100644
--- a/spdx/v2_2/creation_info.go
+++ b/spdx/v2_2/creation_info.go
@@ -22,5 +22,5 @@ type CreationInfo struct {
// 6.10: Creator Comment
// Cardinality: optional, one
- CreatorComment string `json:"comment"`
+ CreatorComment string `json:"comment,omitempty"`
}
diff --git a/spdx/v2_2/document.go b/spdx/v2_2/document.go
index d4d4e50..31ac08b 100644
--- a/spdx/v2_2/document.go
+++ b/spdx/v2_2/document.go
@@ -53,13 +53,13 @@ type Document struct {
DocumentComment string `json:"comment,omitempty"`
CreationInfo *CreationInfo `json:"creationInfo"`
- Packages []*Package `json:"packages"`
- Files []*File `json:"files"`
- OtherLicenses []*OtherLicense `json:"hasExtractedLicensingInfos"`
- Relationships []*Relationship `json:"relationships"`
- Annotations []*Annotation `json:"annotations"`
- Snippets []Snippet `json:"snippets"`
+ Packages []*Package `json:"packages,omitempty"`
+ Files []*File `json:"files,omitempty"`
+ OtherLicenses []*OtherLicense `json:"hasExtractedLicensingInfos,omitempty"`
+ Relationships []*Relationship `json:"relationships,omitempty"`
+ Annotations []*Annotation `json:"annotations,omitempty"`
+ Snippets []Snippet `json:"snippets,omitempty"`
// DEPRECATED in version 2.0 of spec
- Reviews []*Review
+ Reviews []*Review `json:"-"`
}
diff --git a/spdx/v2_2/package.go b/spdx/v2_2/package.go
index 88ae543..2d99e04 100644
--- a/spdx/v2_2/package.go
+++ b/spdx/v2_2/package.go
@@ -9,7 +9,7 @@ type Package struct {
// NOT PART OF SPEC
// flag: does this "package" contain files that were in fact "unpackaged",
// e.g. included directly in the Document without being in a Package?
- IsUnpackaged bool
+ IsUnpackaged bool `json:"-"`
// 7.1: Package Name
// Cardinality: mandatory, one
@@ -45,14 +45,14 @@ type Package struct {
// Cardinality: optional, one; default value is "true" if omitted
FilesAnalyzed bool `json:"filesAnalyzed,omitempty"`
// NOT PART OF SPEC: did FilesAnalyzed tag appear?
- IsFilesAnalyzedTagPresent bool
+ IsFilesAnalyzedTagPresent bool `json:"-"`
// 7.9: Package Verification Code
PackageVerificationCode common.PackageVerificationCode `json:"packageVerificationCode"`
// 7.10: Package Checksum: may have keys for SHA1, SHA256, SHA512 and/or MD5
// Cardinality: optional, one or many
- PackageChecksums []common.Checksum `json:"checksums"`
+ PackageChecksums []common.Checksum `json:"checksums,omitempty"`
// 7.11: Package Home Page
// Cardinality: optional, one
@@ -108,9 +108,9 @@ type Package struct {
PackageAttributionTexts []string `json:"attributionTexts,omitempty"`
// Files contained in this Package
- Files []*File
+ Files []*File `json:"files,omitempty"`
- Annotations []Annotation `json:"annotations"`
+ Annotations []Annotation `json:"annotations,omitempty"`
}
// PackageExternalReference is an External Reference to additional info
@@ -129,5 +129,5 @@ type PackageExternalReference struct {
// 7.22: Package External Reference Comment
// Cardinality: conditional (optional, one) for each External Reference
- ExternalRefComment string `json:"comment"`
+ ExternalRefComment string `json:"comment,omitempty"`
}
diff --git a/spdx/v2_3/creation_info.go b/spdx/v2_3/creation_info.go
index 55fed3d..33b2caf 100644
--- a/spdx/v2_3/creation_info.go
+++ b/spdx/v2_3/creation_info.go
@@ -22,5 +22,5 @@ type CreationInfo struct {
// 6.10: Creator Comment
// Cardinality: optional, one
- CreatorComment string `json:"comment"`
+ CreatorComment string `json:"comment,omitempty"`
}
diff --git a/spdx/v2_3/package.go b/spdx/v2_3/package.go
index d6c4b42..b9d5b95 100644
--- a/spdx/v2_3/package.go
+++ b/spdx/v2_3/package.go
@@ -147,5 +147,5 @@ type PackageExternalReference struct {
// 7.22: Package External Reference Comment
// Cardinality: conditional (optional, one) for each External Reference
- ExternalRefComment string `json:"comment"`
+ ExternalRefComment string `json:"comment,omitempty"`
}