=encoding utf8
=head1 NAME
rdf/serializer/cborld - CBOR-LD serializers.
=head1 EXPORTS
=over
=item C<CborLdSerializer>
Serializes JSON-LD data as plain CBOR surface syntax.
=item C<CompressedCborLdSerializer>
Serializes RDF as tagged compressed CBOR-LD. It uses registry entry 1 by
default, and accepts C<context>, C<registry_entry_id>, and
C<registry_entries> constructor options.
=back
=cut
from rdf/serializer import RdfSerializer;
from rdf/jsonld/core import jsonld_compact, jsonld_data_to_cborld, rdf_to_jsonld_data;
from std/data/cbor import CBOR;
class CborLdSerializer with RdfSerializer {
let Boolean ordered with get := true;
let Boolean use_native_types with get := false;
let Boolean use_rdf_type with get := false;
let rdf_direction with get := null;
method _data ( Array quads ) {
return rdf_to_jsonld_data(quads, {
use_native_types: use_native_types,
use_rdf_type: use_rdf_type,
rdf_direction: rdf_direction,
});
}
method serialize ( Array quads ) {
return ( new CBOR() ).encode(self._data(quads));
}
method serialize_each ( Array quads, Function emit ) {
let data := self.serialize(quads);
emit(data) if data.length() > 0;
return self;
}
}
class CompressedCborLdSerializer with RdfSerializer {
let Boolean ordered with get := true;
let Boolean use_native_types with get := false;
let Boolean use_rdf_type with get := false;
let rdf_direction with get := null;
let context with get := null;
let Number registry_entry_id with get := 1;
let registry_entries with get := null;
method _data ( Array quads ) {
let data := rdf_to_jsonld_data(quads, {
use_native_types: use_native_types,
use_rdf_type: use_rdf_type,
rdf_direction: rdf_direction,
});
return data if context == null;
return jsonld_compact( data, context );
}
method serialize ( Array quads ) {
return ( new CBOR() ).encode(jsonld_data_to_cborld(
self._data(quads),
registry_entry_id: registry_entry_id,
registry_entries: registry_entries,
));
}
method serialize_each ( Array quads, Function emit ) {
let data := self.serialize(quads);
emit(data) if data.length() > 0;
return self;
}
}
modules/rdf/serializer/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