Experimental RDF result set to JSON translator

Introduction

This page provides an experimental RDF to JSON translator as discussed on the linked-data-api wiki. The aim, eventually, is to support a JSON-based publishing format for RDF that is optimised for approachability for normal developers.

It is not intended as a general RDF syntax. In particular, round tripping from RDF through the JSON format and back again is not guaranteed. It will work in the simple 80% of cases. The format includes a context block which records information on the ranges for properties. In cases where a property is used uniformly (object value is always a simple resources, or always a list or always a literal) then round tripping is supported.

The design choices for the JSON format are still under discussion. This translator is intended to make it easy to experiment with the current set of choices to see what it looks like. It will be updated as the design is refined.

Usage

Paste some source RDF into the text area, select the format (Turtle, RDF/XML and N-triple are supported) and click As JSON to get the translated version. The translation includes a wrapper object giving the format version information and a context object to enable round tripping. The translated RDF is in the results array.

{
  "format":"linked-data-api",
  "version":"0.0",
  "results":[
    { ... RDF is here ... }
  ],
  "context":{ ... }
}

In the API itself you can specify a list of root resources to be serialized and the results field will comprise those resources, in order. The web form does not yet support explicit specification of the roots, instead all unique subjects in the source RDF graph will be serialized in a pseudo-random order.

The Pretty print option causes the returned JSON to be indented to make it easy to read.

If a base URL is given then all resource references which extensions of that base URL will be return as relative references and the context block will include the base URL.

Ontology-based configuration

An RDF graph can be serialized with no additional configuration information. Short names for properties will be chosen based on label information in the graph or using the local name.

Optionally a separate ontology can be given which provides label information for properties and, optionally, additional configuration information. The only statements in the ontology that the translator will pay attention to are:

:property rdfs:label "label" .

used to given a short form name to the property when serialized, only applies if the label is an NCName.

:property a lda:Hidden .

used to mark a property to be excluded from the serialization.

:property a lda:Multivalued .

used to mark a property to be always serialized as multivalued (i.e. as a JSON array) irrespective of how many object values it has in any given instance. Without this marker then a property will be serialized as a simple value or an array according to the cardinality of the instance data.

where the namespaces are:

@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix lda: <http://www.epimorphics.com/vocabularies/lda#> .

Programmatic access

This service can be called via a simple POST with the following parameters:

It call also be used in proxy mode by doing a GET with the following parameters:

Note that for the instance which is hosted on Google App Engine then there is a GAE-imposed 30s limit on responses. If the proxied RDF source cannot delivery the complete RDF graph in that time the request will timeout (returning an HTML error page).