=encoding utf8
=head1 NAME
rdf/parser/cborld - CBOR-LD parsers.
=head1 EXPORTS
=over
=item C<CborLdParser>
Parses plain CBOR surface syntax containing JSON-LD data.
=item C<CompressedCborLdParser>
Parses tagged compressed CBOR-LD payloads. Registry entries 0 and 1 are
built in; additional entries may be supplied using the
C<registry_entries> option.
=back
=cut
from rdf/parser import RdfParser;
from rdf/jsonld/core import cborld_to_jsonld_data, jsonld_to_rdf;
from std/data/cbor import CBOR;
class CborLdParser with RdfParser {
method parse_binary ( BinaryString data, ... PairList options ) {
return jsonld_to_rdf( ( new CBOR() ).decode(data), ...options );
}
method parse_string ( String text, ... PairList options ) {
return self.parse_binary( to_binary(text), ...options );
}
method parse_file ( path, ... PairList options ) {
return self.parse_binary( path.slurp(), ...options );
}
method parse_chunks ( Array chunks, ... PairList options ) {
let data := ~to_binary("");
for ( let chunk in chunks ) {
if ( chunk instanceof BinaryString ) {
data _= chunk;
}
else {
data _= to_binary("" _ chunk);
}
}
return self.parse_binary( data, ...options );
}
}
class CompressedCborLdParser with RdfParser {
method parse_binary ( BinaryString data, ... PairList options ) {
return jsonld_to_rdf(
cborld_to_jsonld_data( ( new CBOR() ).decode(data), ...options ),
...options,
);
}
method parse_string ( String text, ... PairList options ) {
return self.parse_binary( to_binary(text), ...options );
}
method parse_file ( path, ... PairList options ) {
return self.parse_binary( path.slurp(), ...options );
}
method parse_chunks ( Array chunks, ... PairList options ) {
let data := ~to_binary("");
for ( let chunk in chunks ) {
if ( chunk instanceof BinaryString ) {
data _= chunk;
}
else {
data _= to_binary("" _ chunk);
}
}
return self.parse_binary( data, ...options );
}
}
modules/rdf/parser/cborld.zzm
rdf-jsonld-0.0.2 source code
Package
- Name
- rdf-jsonld
- Version
- 0.0.2
- Uploaded
- 2026-06-13 00:21:24
- Repository
- https://github.com/tobyink/zuzu-rdf-jsonld
- Dependencies
-
-
html/parser>= 0 -
json/canonicalization>= 0 -
rdf>= 0 -
std/data/cbor>= 0 -
std/data/json>= 0 -
std/data/yaml>= 0 -
std/io>= 0 -
std/string>= 0
-
- Metadata
- zuzu-distribution.json
- Archive
- Download .tar.gz