W3C home > Mailing lists > Public > public-lod@w3.org > December 2009

Re: Creating JSON from RDF

From: Damian Steer <d.steer@bristol.ac.uk>
Date: Sat, 12 Dec 2009 22:33:04 +0000
Cc: Linked Data community <public-lod@w3.org>
Message-Id: <E796FA85-9375-4CBF-BE69-2FFD7FA63C7F@bristol.ac.uk>
To: Jeni Tennison <jeni@jenitennison.com>

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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Saturday, 12 December 2009 22:33:51 GMT