Copyright © 2019-2024 W3C® (MIT, ERCIM, Keio, Beihang). W3C liability, trademark and permissive document license rules apply.
TODO in the end
This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at https://www.w3.org/TR/.
This is an unofficial proposal.
This document was published by the JSON-LD Working Group as an Editor's Draft.
GitHub Issues are preferred for discussion of this specification. Alternatively, you can send comments to our mailing list. Please send them to public-json-ld-wg@w3.org (archives).
Publication as an Editor's Draft does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.
This document was produced by a group operating under the W3C Patent Policy. The group does not expect this document to become a W3C Recommendation. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.
This document is governed by the 1 March 2019 W3C Process Document.
The [RFC7049] is a data format for constrained environments. It is designed to be processable with small code, and to produce small messages. Its underlying data model is an extension of the JSON data model [RFC8259]. That makes it an possible format to transport JSON-LD documents, in constrained contexts such as, e.g., the Web of Things. It also allows JSON-LD contexts to be used to provide a layer of semantics on existing CBOR data.
More specifically, this note specifies how to convert between the CBOR data format and the JSON-LD internal representation (a is straightforward abstraction of the JSON format ). Since CBOR emphasizes small messages, we also propose a number of techniques for reducing the size of messages.
To understand this note you must be familiar both the JSON format [RFC8259] and the CBOR format [RFC7049]. You must also understand the basics of JSON-LD 1.1 [JSON-LD11].
While being generally based on the JSON data model, the CBOR specification does not specify a standard conversion between both models. This is due in part to the fact that the CBOR model is an extension of the former. In this section, we provide a complete specification of such a conversion, following the guidelines from §4.2 of RFC7049, and taking into account the particularities of JSON-LD.
null
, 20 for false
and 21 for true
.
@type
of xsd:integer
(TODO full IRI),
an if its @value
is a valid decimal representation of an integer,
then the object is serialized as a CBOR integer (major type 0 or 1)
choosing the shortest form.
@type
of xsd:base64Binary
(TODO full IRI),
an if its @value
complies with the
lexical space
of xsd:base64Binary
(i.e. is it a valid base 64 string [RFC3548]),
then the JSON object is serialized as a CBOR binary string
(major type 2) representing the decoded value.
This section describes how to parse CBOR data into the JSON-LD internal representation, following the guidelines from §4.1 of RFC7049. It is the inverse process of the one described in .
@type
entry whose value is xsd:integer
(TODO full IRI),@value
entry whose value is a decimal representation of the integer, as a string.@type
entry whose value is xsd:base64Binary
(TODO full IRI),@value
entry whose value is the base 64 encoding of the binary string, complying with the constraints on the
lexical space
of xsd:base64Binary
.
false
if the additional type value is 20,true
if the additional type value is 21,@type
entry whose value is xsd:double
(TODO full IRI),
@value
entry whose value is the string NaN
, INF
or -INF
, respectively.
NaN
, positive infinity nor negative infinity,TODO
TODO propose numeric aliases for keywords, and possibly often used IRIs?
TODO do no alias keywords, do not use type coercion, define small prefixes, more...
rdf:CBOR
datatype
The intent of this datatype is to make it possible to convey CBOR data as
RDF literals.
It is defined as a subset of
the xsd:base64Binary
datatype.
The rdf:CBOR
datatype is defined as follows:
http://www.w3.org/1999/02/22-rdf-syntax-ns#CBOR
.xsd:base64Binary
,
for which the lexical mapping produces well-formed CBOR data [RFC7049].
xsd:base64Binary
datatype [XSD].