Copyright © 2011-2013 W3C® (MIT, ERCIM, Keio, Beihang), All Rights Reserved. W3C liability, trademark and document use rules apply.
The Resource Description Framework (RDF) is a framework for representing information in the Web.
This document defines a textual syntax for RDF called RDF/JSON that allows an RDF graph to be completely written in a form compatible with the JavaScript Object Notation (JSON) [RFC4627] and alternative to the one recommended in JSON-LD [JSON-LD].
The syntax defined in this document should not be used unless there is a specific reason to do so. Use of JSON-LD is recommended.
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 http://www.w3.org/TR/.
Important Note: The RDF Working Group has decided not to push this document through the W3C Recommendation Track. You should therefore not expect to see this document eventually become a W3C Recommendation.
This document was published as a Working Group Note to provide those who are using it and/or have an interest in it with a stable reference.
The RDF Working Group decided to put JSON-LD on the Recommendation track. Therefore, unless you have a specific reason to use the syntax defined in this document instead of JSON-LD, you are encouraged to use JSON-LD.
This document was published by the RDF Working Group as a Working Group Note. If you wish to make comments regarding this document, please send them to public-rdf-comments@w3.org (subscribe, archives). All comments are welcome.
Publication as a Working Group Note 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 5 February 2004 W3C Patent Policy. 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 defines RDF/JSON, a concrete syntax for RDF, as defined in the RDF Concepts and Abstract Syntax W3C Recommendation [RDF11-CONCEPTS], in JavaScript Object Notation (JSON) [RFC4627].
The syntax defined in this document is an alternative to the one recommended in JSON-LD [JSON-LD]. It should not be used unless there is a specific reason to do so. Use of JSON-LD is recommended.
As well as sections marked as non-normative, all authoring guidelines, diagrams, examples, and notes in this specification are non-normative. Everything else in this specification is normative.
The key words MUST, MUST NOT, REQUIRED, SHOULD, SHOULD NOT, RECOMMENDED, MAY, and OPTIONAL in this specification are to be interpreted as described in [RFC2119].
This section is non-normative.
An RDF Graph consists of a set of RDF triples, each triple consisting of a subject, a predicate and an object (formally defined in [RDF11-CONCEPTS]). An RDF/JSON document serializes such a set of RDF triples as a series of nested data structures.
A conforming RDF/JSON document consists of a single JSON object called the root object. Each unique subject in the set of triples is represented as a key in the root object. No key may appear more than once in the root object.
The value of each root object key is a further JSON object whose keys are the URIs of the predicates occuring in triples with the given subject. These keys are known as predicate keys. No predicate key may appear more than once within a single object.
The value of each predicate key is an array of JSON objects representing the object of each serialized triple.
In general, a triple (subject S, predicate P, object O) is serialized in the following structure:
{ "S" : { "P" : [ O ] } }
The object of the triple O is represented as a further JSON object with the following keys:
Blank node subjects are named using a string conforming to the nodeID production in Turtle. For example: _:A1
The 'lang' and 'datatype' keys should only be used if the value of the 'type' key is "literal".
All keywords defined in this document are case sensitive, and must be lowercase.
Given a set of RDF Triples an RDF/JSON document may be constructed using the following algorithm:
This section is non-normative.
An example of a single triple with a literal object having a language of "en"
{ "http://example.org/about" : { "http://purl.org/dc/terms/title" : [ { "value" : "Anna's Homepage", "type" : "literal", "lang" : "en" } ] } }
This is equivalent to the following N-Triples [N-TRIPLES]:
<http://example.org/about> <http://purl.org/dc/terms/title> "Anna's Homepage"@en .
An example of two triples that share the same subject and predicate but have differing objects:
{ "http://example.org/about" : { "http://purl.org/dc/terms/title" : [ { "value" : "Anna's Homepage", "type" : "literal", "lang" : "en" }, { "value" : "Annas hjemmeside", "type" : "literal", "lang" : "da" } ] } }
This is equivalent to the following N-Triples:
<http://example.org/about> <http://purl.org/dc/terms/title> "Anna's Homepage"@en . <http://example.org/about> <http://purl.org/dc/terms/title> "Annas hjemmeside"@da .
An example of a triple with a datatyped literal object:
{ "http://example.org/about" : { "http://purl.org/dc/terms/title" : [ { "value" : "<p xmlns=\"http://www.w3.org/1999/xhtml\"><b>Anna's</b> Homepage>/p>", "type" : "literal", "datatype" : "http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral" } ] } }
This is equivalent to the following N-Triples:
<http://example.org/about> <http://purl.org/dc/terms/title> "<p xmlns=\"http://www.w3.org/1999/xhtml\"><b>Anna's</b> Homepage>/p>"^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral> .
An example of triples with a common blank node:
{ "http://example.org/about" : { "http://purl.org/dc/terms/creator" : [ { "value" : "_:anna", "type" : "bnode" } ] , "_:anna" : { "http://xmlns.com/foaf/0.1/name" : [ { "value" : "Anna", "type" : "literal" } ] } }
This is equivalent to the following N-Triples:
<http://example.org/about> <http://purl.org/dc/terms/creator> _:anna . _:anna <http://xmlns.com/foaf/0.1/name> "Anna" .
An example of a triple with a URI object:
{ "_:anna" : { "http://xmlns.com/foaf/0.1/homepage" : [ { "value" : "http://example.org/anna", "type" : "uri" } ] } }
This is equivalent to the following N-Triples:
_:anna <http://xmlns.com/foaf/0.1/homepage> <http://example.org/anna> .
An example of triples with common subjects:
{ "_:anna" : { "http://xmlns.com/foaf/0.1/name" : [ { "value" : "Anna", "type" : "literal" } ], "http://xmlns.com/foaf/0.1/homepage" : [ { "value" : "http://example.org/anna", "type" : "uri" } ] } }
This is equivalent to the following N-Triples:
_:anna <http://xmlns.com/foaf/0.1/name> "Anna" . _:anna <http://xmlns.com/foaf/0.1/homepage> <http://example.org/anna> .
An empty RDF graph is serialized as a JSON object with zero keys.
{ }
This section is non-normative.
This document is based on original work from Talis [TALIS-RDF-JSON] and has benefited from the review of the RDF WG, especially Andy Seaborne and Pierre-Antoine Champin.
The suggested media type for RDF/JSON is "application/rdf+json".
It is suggested that RDF/JSON files have the extension ".rj" (all lowercase) on all platforms.
JSON is encoded in Unicode, with a default encoding of UTF-8. See RFC627, section 3 "Encoding".