modules/rdf/jsonld.zzm

rdf-jsonld-0.0.2 documentation

Package

Name
rdf-jsonld
Version
0.0.2
Uploaded
2026-06-13 00:21:24
Repository
https://github.com/tobyink/zuzu-rdf-jsonld
Dependencies
Metadata
zuzu-distribution.json
Archive
Download .tar.gz

NAME

rdf/jsonld - JSON-LD parser and serializer facade.

SYNOPSIS

  from rdf/jsonld import
      JsonLdParser,
      JsonLdSerializer,
      jsonld_expand,
      jsonld_compact,
      jsonld_flatten,
      jsonld_frame,
      jsonld_decode_text;

  let expanded := jsonld_expand(data, { base: "https://example.test/" });
  let compacted := jsonld_compact(expanded, {
      "@context": { ex: "https://example.test/" },
  });
  let flattened := jsonld_flatten(data);

DESCRIPTION

This module re-exports the JSON-LD, YAML-LD, CBOR-LD, and compressed CBOR-LD RDF parser and serializer classes, plus the public JSON-LD API functions implemented by this distribution.

The parser and serializer classes operate on RDF quads and compose the RdfParser and RdfSerializer traits from the main rdf distribution. The JSON-LD API functions operate on decoded JSON-like ZuzuScript data structures.

EXPORTS

Classes

  • JsonLdParser, YamlLdParser, CborLdParser, CompressedCborLdParser

    Parse JSON-LD, YAML-LD, plain CBOR-LD, or compressed CBOR-LD into RDF quads, or into a supplied RDF store via the into option.

  • JsonLdSerializer, YamlLdSerializer, CborLdSerializer, CompressedCborLdSerializer

    Serialize RDF quads as expanded JSON-LD data encoded as JSON, YAML, or CBOR. The compressed CBOR-LD serializer emits tagged CBOR-LD using registry entry 1 by default.

Functions

  • jsonld_expand(data, options?)

    Expands a JSON-LD document into expanded JSON-LD form. Supported options include base, compact_arrays, expand_context, and document_loader. document_loader may be a function taking a URL or an object with load_document(url); it should return either decoded JSON-LD data or a remote document dictionary with document, document_url, content_type, and context_url keys.

  • jsonld_decode_text(text, options...)

    Decodes JSON text, or extracts JSON-LD script elements from HTML when content_type contains html or the text looks like an HTML document. HTML extraction supports base for fragment targeting and extract_all_scripts.

  • jsonld_compact(data, context, options?)

    Expands data and compacts it using context. The result includes @context.

  • jsonld_flatten(data, context?, options?)

    Expands and flattens data. When context is supplied, the flattened result is compacted using that context.

  • jsonld_frame(data, frame, options?)

    Expands, flattens, frames, and compacts data using a JSON-LD frame. The implementation supports graph/type framing with nested node embedding and uses the frame @context as the output context.

  • jsonld_to_rdf, rdf_to_jsonld_data

    Lower-level ToRDF and FromRDF helpers used by the parser and serializer classes.

  • cborld_to_jsonld_data, jsonld_data_to_cborld

    Lower-level helpers for converting between decoded JSON-LD data and tagged CBOR-LD values.

  • jsonld_object_equals

    Compares JSON-LD result objects in tests while ignoring object member ordering.

COPYRIGHT AND LICENCE

rdf/jsonld is copyright Toby Inkster.

It is free software; you may redistribute it and/or modify it under the terms of either the Artistic License 1.0 or the GNU General Public License version 2.