RDF/XML sucks: People loudly complain about RDF/XML, the standard serialization format of RDF graphs into XML. It’s crufty, it’s buggy, it misses the point, it’s a royal pain. Turtle/N3 is better for reading and writing by humans, but writing a parser is still a lot of work. A number of simpler XML alternatives have been proposed, e.g. TriX and RPV and RXR, but neither has gained major support.

The Serializing SPARQL Results as JSON note shows how to represent SPARQL SELECT results – which are normally XML files – as JSON structures. That’s great for doing AJAXy stuff. It’s supported in a number of SPARQL engines, such as Joseki, ARC, Redland/Rasqual and D2R Server. There’s a Javascript library for client-side processing. Working with it is fast, efficient and fun.

RDF/JSON: Now this is kind of obvious: You can use SPARQL/JSON to serialize RDF graphs. A table with three columns, s, p, o, with each row being one RDF triple.

<http://richard.cyganiak.de/foaf.rdf#cygri> rdf:type foaf:Person;
    foaf:name "Richard Cyganiak";
    foaf:mbox <mailto:richard@cyganiak.de>;

This simple graph serializes to:

  "head": {
    "vars": [ "s" , "p" , "o" ]
  } ,
  "results": {
    "distinct": false ,
    "ordered": false ,
    "bindings": [
        "s": { "type": "uri" , "value": "http://richard.cyganiak.de/foaf.rdf#cygri" } ,
        "p": { "type": "uri" , "value": "http://www.w3. org/1999/02/22-rdf-syntax-ns#type" } ,
        "o": { "type": "uri" , "value": "http://xmlns.com/foaf/0.1/Person" }
      } ,
        "s": { "type": "uri" , "value": "http://richard.cyganiak.de/foaf.rdf#cygri" } ,
        "p": { "type": "uri" , "value": "http://xmlns.com/foaf/0.1/name" } ,
        "o": { "type": "literal" , "value": "Richard Cyganiak" }
      } ,
        "s": { "type": "uri" , "value": "http://richard.cyganiak.de/foaf.rdf#cygri" } ,
        "p": { "type": "uri" , "value": "http://xmlns.com/foaf/0.1/mbox" } ,
        "o": { "type": "uri" , "value": "mailto:richard@cyganiak.de" }

Here’s my entire FOAF file in RDF/JSON.

Emitting RDF/JSON: Every JSON-capable SPARQL processor will emit this serialization by answering this query:

SELECT ?s ?p ?o WHERE { ?s ?p ?o }


Consuming RDF/JSON: It’s trivial from Javascript, and there’s JSON parsers for just about any language under the sun.

Do we need this? I think it’s useful. Javascript is the duct tape of Web 2.0, and a simple and convenient method of consuming and producing RDF from Javascript will be important.


  • JSON support in all SPARQL endpoints (please please please!)
  • An online service that transforms RDF/XML and Turtle to RDF/JSON
  • A simple Javascript library that implements find(s/p/o) on RDF/JSON models
  • A convention for putting namespace prefix declarations and the base URI into RDF/JSON.

(This post was triggered by this thread, started by Björn Thalheim, on jena-dev. Update: Björn has code for turning Jena models into RDF/JSON and back.)

This entry was posted in General, Semantic Web. Bookmark the permalink.

1 Response to RDF/JSON

  1. Here is a site/project that does just what you are asking for:



Comments are closed.