Re: Creating JSON from RDF

On 12 Dec 2009, at 21:42, Jeni Tennison wrote:

> Hi,
> 
> As part of the linked data work the UK government is doing, we're looking at how to use the linked data that we have as the basis of APIs that are readily usable by developers who really don't want to learn about RDF or SPARQL.

> # SPARQL Results #


> 
>  {
>    "head": {
>      "vars": [ "book", "title" ]
>    },
>    "results": {
>      "bindings": [
>        {
>          "book": {
>            "type": "uri",
>            "value": "http://example.org/book/book6"
>          },
>          "title": {
>            "type": "literal",
>            "value", "Harry Potter and the Half-Blood Prince"
>          }
>        },
>        {
>          "book": {
>            "type": "uri",
>            "value": "http://example.org/book/book5"
>          },
>          "title": {
>            "type": "literal",
>            "value": "Harry Potter and the Order of the Phoenix"
>          }
>        },
>        ...
>      ]
>    }
>  }
> 
> a normal developer would want to just get:
> 
>  [{
>    "book": "http://example.org/book/book6",
>    "title": "Harry Potter and the Half-Blood Prince"
>   },{
>     "book": "http://example.org/book/book5",
>     "title": "Harry Potter and the Order of the Phoenix"
>   },
>   ...
>  ]

In terms of code accessing the results there isn't much difference. The former requires an initial path to the array ['results']['bindings'], then the use of ['value'] for each access.

Damian

Received on Saturday, 12 December 2009 22:33:49 UTC