Usability of JSON Serializations of RDF

Thomas Steiner produced a wiki page showing how various RDF + JSON proposals serialized a particular RDF graph as part of the RDF working group's work in this area. I found it particularly interesting because I'm the main originator of one of the proposals (RDF/JSON) and I looked at all the issues the WG is considering when writing it.

One of the things I think would be useful is to include examples of how a Javascript developer would use each serialization for various tasks. Here's what some could look like in RDF/JSON:

Get a photo of Jon:

data['http://jondoe.example.org/#me']['http://xmlns.com/foaf/0.1/depiction'][0]['value'];

Get the names of Jon's friends:

var knows = data['http://jondoe.example.org/#me']['http://xmlns.com/foaf/0.1/knows'];
for (var i=0; i < knows.length; i++) {
  alert(data[knows[i]['value']]['http://xmlns.com/foaf/0.1/name'][0]['value']); 
}

Get the french description of Jon:

var descriptions = data['http://jondoe.example.org/#me']['http://xmlns.com/foaf/0.1/description'];
for (var i=0; i < descriptions.length; i++) {
  if (descriptions[i]['lang'] == 'fr') {
    alert(descriptions[i]['value']); 
  }
}

I also noticed that there are missing commas between the resource blocks {} in the RDF/JSON example. That JSON isn't quite valid because of that but it doesn't get in the way of what Thomas is trying to show.

BTW, I am writing this as a blog post because there isn't a good way to supply feedback to a W3C working group that is still in the exploratory phase. I would either have to join the group or post to the comments list which seems inappropriate for a side discussion like this especially since this is not an official WG document.

Permalink: http://blog.iandavis.com/2011/04/rdf-json-usability/

Other posts tagged as json, rdf, technology

Earlier Posts