SamuraiAku / SPDX.jl

Provides for the creation, reading and writing of SPDX files in multiple file formats. Written in pure Julia.
MIT License
5 stars 1 forks source link

JSON document read fails if there are no packages #18

Closed SamuraiAku closed 1 year ago

SamuraiAku commented 1 year ago

In a fully compliant document there should always be at least one package, but it would be better to not error out for a document-in-progress

Example document:

{
    "spdxVersion" : "SPDX-2.2",  
    "dataLicense" : "CC0-1.0",                  
    "SPDXID" : "SPDXRef-DOCUMENT",   
    "name" : "SPDX.jl",
    "documentNamespace" : "http://spdx.org/spdxdocs/spdx-example-444504E0-4F89-41D3-9A0C-0305E82C3301"
}

Read Failure:

julia> readspdx("json_readFail.json")
ERROR: KeyError: key "packages" not found
Stacktrace: .......

Workaround is to add an empty packages field like so:

"packages" : []