Repository navigation
Releases: rasuvaeff/json-ld
Releases · rasuvaeff/json-ld
Release list
v1.0.0
v0.2.0
The pre-1.0 contract wave: every break below is deliberate, the API of this release is
meant to become 1.0 unchanged.
- BC:
ExpandOptionsis renamedProcessingOptions(it configures every operation),
and its constructor order is nowbase, documentUrl, expandContext, loader, maxDepth, maxBytes. Migration: rename the class; positional calls must switch to named arguments. - Added
ProcessingOptions::$maxDepth(default 512, the previous fixed cap) and
$maxBytes(default no limit): guards for untrusted JSON strings, checked before and
while decoding and during expansion (document too large,document nested too deeply).
Depth now counts nested arrays and objects, asjson_decode()does, not every value. - BC:
JsonLd::document()builds the node API from the node map (the structure
flattening uses): embedded nodes without@id— a schema.orgauthor— are now nodes,
reachable throughNode::reference(), and get blank node labels_:b0,_:b1, …;
blank node labels of the input are relabeled the same way; nested@graphs become
graphs of their own; a bare{"@id": …}reference is a node without properties.
Node::properties()/toArray()hold references instead of embedded objects.
Migration: followreference()instead of reading embedded arrays; do not rely on
input blank node labels. - BC:
Graph\Document's constructor is private; useDocument::fromExpanded().
Graph\Graphtakes node objects in flattened form. - Added
Node::valueObjects()returningGraph\Value(value, language, datatype,
direction): language-tagged values no longer lose their tag.Node::values()and
friends accept single-valued members such as@index. - BC: whatever a
ContextLoaderInterfacethrows now surfaces as
DocumentLoadingExceptionwith the loader's exception as the previous one:
loading remote context failedfor contexts (it was anInvalidContextException,
and non-DocumentLoadingExceptionthrowables escaped unwrapped),loading document failed
for a document URL (inside a term's scoped@contextthe W3C algorithm still reports
invalid scoped context, now with theDocumentLoadingExceptionas previous).
Migration: catchDocumentLoadingException/JsonLdException
instead ofInvalidContextExceptionorRuntimeException. - BC: exceptions carry an error code:
JsonLdException::errorCode(): ErrorCode(W3C
JSON-LD 1.1 API codes plusrecursive context inclusionand four processor codes:
document nested too deeply,document too large,invalid N-Quads,
canonicalization limit exceeded). The constructor is
(ErrorCode $errorCode, ?string $message = null, ?Throwable $previous = null); the
message defaults to the code.InvalidJsonExceptionreportsloading document failed
with the JSON error as its message. Migration: branch onerrorCode(), not on the
message; custom loaders that throwDocumentLoadingExceptionpass a code (or throw
anything — it is wrapped). - BC:
Dataset::canonicalHash()now implements W3C RDF Dataset Canonicalization
RDFC-1.0 (SHA-256 of the canonical N-Quads) instead of a home-grown algorithm, so hash
values change;Dataset::equals()compares canonical N-Quads. Migration: recompute
stored hashes. - Added
Dataset::canonicalNQuads(),Rdf\Canonicalizer(hash algorithm, work factor),
Rdf\CanonicalForm(canonical N-Quads, issued identifiers,hash()),
Rdf\HashAlgorithm(SHA-256, SHA-384) andException\CanonicalizationLimitException:
poison graphs stop afterworkFactor × nHash N-Degree Quads runs per blank node
(default factor 4). The W3C rdf-canon suite passes 86 of 86 (64 evaluation, 21 map,
1 negative), nothing skipped. Documented limitation of the specification: blank nodes that
differ only in which named graph their relations live in tie, and the input quad order
decides between equally valid canonical forms. - BC:
rdfDirectionofJsonLd::toRdf()/fromRdf()is the enumRdfDirection
(I18nDatatype,CompoundLiteral). Migration:'i18n-datatype'→
RdfDirection::I18nDatatype,'compound-literal'→RdfDirection::CompoundLiteral. - BC: the RDF vocabulary constants moved from
Rdf\LiteraltoRdf\Vocabulary
(Literal::XSD_STRING→Vocabulary::XSD_STRING, likewiseRDF_LANGSTRING,RDF_JSON,
RDF_FIRST,RDF_REST,RDF_NIL,RDF_TYPE; new:XSD_BOOLEAN,XSD_INTEGER,
XSD_DOUBLE,RDF_LIST,RDF_VALUE,RDF_LANGUAGE,RDF_DIRECTION,I18N). - BC:
Dataset::quads()is removed; read theDataset::$quadsproperty, as on the
other RDF value objects. - BC: internal methods left the public classes:
Expander::expandRaw()and
NQuads::formatTerm()are gone,Flattenerno longer takes anExpander. - Added
Loader\MapContextLoader: a fixed URL → document map, exact match, no I/O. - README states the scope (no compaction or framing in 1.0) and that the package reads
JSON-LD rather than emitting schema.org markup.
v0.1.0
- JSON-LD 1.1 expansion, flattening, node API, RDF conversion (
toRdf,fromRdf) and N-Quads. - W3C JSON-LD API test suite: expand 368/368, flatten 54/55 (one
compactArrayscase skipped), toRdf 447/448 (one empty-object JSON literal case skipped), fromRdf 53/53. Compaction, framing and the 1.0 processing mode are not implemented. - Context loading only through an injected
ContextLoaderInterface; the defaultInlineContextLoaderrefuses URLs,PsrContextLoadertakes a URL policy closure and a body size limit. - Checked on 14 JSON-LD blocks collected from real pages (Wikipedia, YouTube, BBC, The New York Times, IMDb, Kommersant, Championat and others): expansion and flattening give the same RDF, N-Quads and
fromRdfround-trip. - Mutation score 98.3% (
minMsi92).