CycloneDX/sbom-utility

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

開放

#143 建立於 2026年1月9日

 (1 則留言) (0 個反應) (0 位負責人)Go (20 個分叉)auto 404
enhancementhelp wanted

倉庫指標

星標
 (155 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

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:

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": "

貢獻者指南