W3C home > Mailing lists > Public > public-linked-json@w3.org > January 2014

Re: SPARQL and JSON-LD

From: Gregg Kellogg <gregg@greggkellogg.net>
Date: Tue, 21 Jan 2014 10:25:31 -0800
Cc: Linked JSON <public-linked-json@w3.org>
Message-Id: <6B4C687B-62FB-494B-B62D-92CA48934B74@greggkellogg.net>
To: Andy Seaborne <andy.seaborne@epimorphics.com>
On Jan 21, 2014, at 6:44 AM, Andy Seaborne <andy.seaborne@epimorphics.com> wrote:

> So (Markus? :) what would one look like?
> 
> 	Andy

Clearly "Query Results" is ambigious; for CONSTRUCT/DESCRIBE, any RDF serialization is useful, and I think that might be the point of the reference Markus showed. My own SPARQL implementation serializes to about 10 different RDF formats. Result sets are different, as noted: they are tabular. To serialize a result set as JSON-LD would require a vocabulary for describing result sets, but if this existed, then it could be used to serialize in any RDF format.

However, another way to look at it is, if there were a result set vocabulary (I haven't found one), then could the SPARQL JSON result set format be marked up to also be JSON-LD, with the addition of an appropriate context? Close, but not quite. "head" could be ignored, "results" could be aliased to @graph, "bindings" could be an appropriate predicate which has @container: @list. Each row is then a BNode with predicates assigned to each variable. Unfortunately, the value comes close to looking like either a node reference or an expanded value, but not quite.

A result-set vocabulary favoring a JSON-LD expression could then replace the "head" section with a context that applies appropriate meaning to each binding, where the values are objects represented in expanded form. An alternative to the example in section 2 of <http://www.w3.org/TR/sparql11-results-json/> might be:

{
  "@context": {
    "results": "@graph",
    "sb": "http://example/sparql-bindings#",
    "dc": "http://purl.org/dc/terms/",
    "bindings": {"@id": "sb:bindings", "@container": "@list"},
    "book": "dc:bibliographicCitation",
    "title": "dc:title"
  },
  "results": { 
    "bindings": [
      {
        "book": { "@id": "http://example.org/book/book6" } ,
        "title": { "@value": "Harry Potter and the Half-Blood Prince" }
      } ,
      {
        "book": { "@id": "http://example.org/book/book7" } ,
        "title": { "@value": "Harry Potter and the Deathly Hallows" }
      } ,
      {
        "book": { "@id": "http://example.org/book/book5" } ,
        "title": { "@value": "Harry Potter and the Order of the Phoenix" }
      } ,
      {
        "book": { "@id": "http://example.org/book/book4" } ,
        "title": { "@value": "Harry Potter and the Goblet of Fire" }
      } ,
      {
        "book": { "@id": "http://example.org/book/book2" } ,
        "title": { "@value": "Harry Potter and the Chamber of Secrets" }
      } ,
      {
        "book": { "@id": "http://example.org/book/book3" } ,
        "title": { "@value": "Harry Potter and the Prisoner Of Azkaban" }
      } ,
      {
        "book": { "@id": "http://example.org/book/book1" } ,
        "title": { "@value": "Harry Potter and the Philosopher's Stone" }
      }
    ]
  }
}

In many cases, the variables could be the same as the predicate that is selected. Obviously, in others it's not and some document-level variable space could be more useful.

Any way, just a thought experiment.

Gregg

> On 21/01/14 14:08, Ivan Herman wrote:
>> Andreas,
>> 
>> to be very factual: no, at this moment there is no official W3C Working Group working on such a formal specification. And I do not know of any plans to do so in the foreseeable future (although I agree that it would be ok to have such a document).
>> 
>> Whether there are groups or individuals doing so, I do not know...
>> 
>> Sincerely
>> 
>> Ivan
>> 
>> On 21 Jan 2014, at 14:35 , Andreas Kuckartz <a.kuckartz@ping.de> wrote:
>> 
>>> Hi Kingsley,
>>> 
>>> thanks for the links and the information.
>>> 
>>>> What isn't offered is a JSON-LD based self-describing SPARQL result
>>>> which is a consequence of this not really being part of the SPARQL spec.
>>> 
>>> But a W3C Recommendation similar to this one could be created for JSON-LD:
>>> 
>>> SPARQL 1.1 Query Results JSON Format
>>> W3C Recommendation 21 March 2013
>>> http://www.w3.org/TR/sparql11-results-json/
>>> 
>>> Is anyone working on a "SPARQL 1.1 Query Results JSON-LD Format"?
>>> 
>>> Cheers,
>>> Andreas
>>> 
>> 
>> 
>> ----
>> Ivan Herman, W3C
>> Digital Publishing Activity Lead
>> Home: http://www.w3.org/People/Ivan/
>> mobile: +31-641044153
>> GPG: 0x343F1A3D
>> FOAF: http://www.ivan-herman.net/foaf
>> 
>> 
>> 
>> 
>> 
> 
Received on Tuesday, 21 January 2014 18:26:03 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 16:18:40 UTC