CycloneDX / CycloneDX/sbom-utility

Explore support for SPDX 3.x validation and conformance with JSON-LD

Open
#143 1 comment 0 reactions 0 assignees View on GitHub
enhancement help wanted
Dominant language
Go
Stars
163
Forks
21
PR merge metrics
No merged PRs in 30d

Description

As it appears official JSON schema support (via serialization) has been abandoned we must look to see what we can do with JSON-LD and limited support for it in Golang...

**References**:
- _A.1 Differences between V3.0 and V2.3_ : https://github.com/spdx/using/blob/main/docs/diffs-from-previous-editions.md/
- "hello world" example: https://github.com/spdx/spdx-spec/blob/support/3.0/examples/jsonld/package_sbom.json
- Use as a starting point (testcase)

See: https://github.com/piprate/json-gold/

e.g.,
```
import (
"fmt"
"github.com/piprate/json-gold/ld"
)

func processAndValidateJSONLD(jsonData string) error {
proc := ld.NewJsonLdProcessor()
options := ld.NewJsonLdOptions()
// Set the processing mode to the latest spec (e.g., "json-ld-1.1")
options.ProcessingMode = "json-ld-1.1"

// The Expand function will return an error if the JSON-LD is invalid
expandedDoc, err := proc.Expand("https://example.com/some-base-url", jsonData, options)
if err != nil {
return fmt.Errorf("JSON-LD validation error: %w", err)
}

fmt.Printf("JSON-LD document successfully processed (expanded), contains %d top-level elements.\n", len(expandedDoc.([]interface{})))
return nil
}

func main() {
doc := `{
"@context": "
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.