Documentation
¶
Overview ¶
Package jsonld implements a JSON-LD parser and serializer using piprate/json-gold.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Parse ¶
Parse parses a JSON-LD document into the given graph. It uses piprate/json-gold to expand the document to N-Quads, then parses those into the graph. Options: WithBase, WithDocumentLoader, WithSkipInvalidIRIs, WithUnboundedLines.
Types ¶
type Option ¶
type Option func(*config)
Option configures JSON-LD parsing or serialization.
func WithDocumentLoader ¶
func WithDocumentLoader(loader ld.DocumentLoader) Option
WithDocumentLoader sets a custom document loader for remote context resolution.
func WithExpanded ¶
func WithExpanded() Option
WithExpanded is a convenience option to request expanded JSON-LD output.
func WithForm ¶
func WithForm(form OutputForm) Option
WithForm sets the output form for JSON-LD serialization (compact or expanded).
func WithSkipInvalidIRIs ¶ added in v0.1.10
func WithSkipInvalidIRIs() Option
WithSkipInvalidIRIs makes parsing tolerant of syntactically invalid IRIs (e.g. a stray space, as in "schema: Dataset") that the JSON-LD expander emits into the intermediate N-Quads instead of dropping. The offending triple is silently skipped and parsing continues, rather than failing the whole document.
This matches Python rdflib/pySHACL, which drop such triples before validation. The default (option unset) is strict: an invalid IRI is a hard error. Note that the bundled JSON-LD processor already drops most malformed IRIs on its own; this option is a safety net for IRIs that slip through to the N-Quads layer.
func WithUnboundedLines ¶ added in v0.1.11
func WithUnboundedLines() Option
WithUnboundedLines parses intermediate N-Quads lines of arbitrary length, growing the read buffer as needed. This is useful when JSON-LD expansion produces very large literal values on a single N-Quads line.
type OutputForm ¶
type OutputForm int
OutputForm specifies the JSON-LD output format.
const ( // FormCompacted applies JSON-LD compaction using namespace bindings (default). FormCompacted OutputForm = iota // FormExpanded outputs expanded JSON-LD without compaction. FormExpanded )