- From: Niklas Lindström <lindstream@gmail.com>
- Date: Tue, 15 Mar 2016 16:29:12 +0100
- To: Jean-Claude Moissinac <jean-claude.moissinac@telecom-paristech.fr>
- Cc: "public-linked-json@w3.org" <public-linked-json@w3.org>
- Message-ID: <CADjV5jdoeVcK1Lm4_L28fSQn1UFZv1bkY2ouVgs_ygK9z68QkA@mail.gmail.com>
Hi Jean-Claude, SPARQL SELECT results (regardless of in XML or JSON) do not represent RDF, only tabular results. To get JSON-LD, you need to use the results of a SPARQL CONSTRUCT query. Some systems support returning that as JSON-LD, but perhaps only expanded or using a predetermined context. Some may only return RDF/XML and/or Turtle. In either case CONSTRUCT results represent RDF and you can turn that into JSON-LD using any context you like on your end (and any method of framing). Best regards, Niklas (PS. I once made a thing that turned these tabular results into a tree (with nesting determined by the variable names). That was fairly close to the shape of JSON-LD (this was before JSON-LD came to be). I cannot say I recommend this today, but you might want to take a look at: https://github.com/niklasl/oort/blob/wiki/SparqlTree.md Along with a JS-implementation here: https://github.com/niklasl/oort.js/blob/master/src/oort/sparqltree.js) On Tue, Mar 15, 2016 at 2:33 PM, Jean-Claude Moissinac < jean-claude.moissinac@telecom-paristech.fr> wrote: > I'm trying to find best practices in the use of a json output from a > sparql endpoint > For exemple the request on dbpedia : > prefix schema: <http://schema.org/> > select distinct ?p ?name ?lat ?lon where { > ?p a schema:Place . > ?p rdfs:label ?name . > ?p geo:lat ?lat . > ?p geo:long ?lon . > } LIMIT 5 > give me as json output > > { "head": { "link": [], "vars": ["p", "name", "lat", "lon"] }, > "results": { "distinct": false, "ordered": true, "bindings": [ > { "p": { "type": "uri", "value": "http://dbpedia.org/resource/Cameron_Parish,_Louisiana" } , "name": { "type": "literal", "xml:lang": "en", "value": "Cameron Parish, Louisiana" } , "lat": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#float", "value": "29.85" } , "lon": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#float", "value": "-93.2" }}, > { "p": { "type": "uri", "value": "http://dbpedia.org/resource/Cameron_Parish,_Louisiana" } , "name": { "type": "literal", "xml:lang": "ar", "value": "\u0645\u0642\u0627\u0637\u0639\u0629 \u0643\u0627\u0645\u064A\u0631\u0648\u0646 (\u0644\u0648\u064A\u0632\u064A\u0627\u0646\u0627)" } , "lat": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#float", "value": "29.85" } , "lon": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#float", "value": "-93.2" }}, > ... < cut for clarity > > > }} ] } } > > We loose the fact that ?p is a Place. We can factorize the 'type' on the > table of results. And finally get a table of objects like thos one > { > "p ": "http://dbpedia.org/resource/Cameron_Parish,_Louisiana", > "name": "Cameron Parish, Louisiana", > "pos": { "lat": 29.85, "long": 93.2 } > } > > I suppose some results can be obtained by using a context and some others > by framing. > > Can we point me on ideas for clarification? > > Many thanks in advance > > -- > Jean-Claude Moissinac > > > Cet e-mail a été envoyé depuis un ordinateur protégé par Avast. > www.avast.com > <https://www.avast.com/fr-fr/lp-safe-emailing?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=OA-2109-A> > <#-6989394509917606694_DDB4FAA8-2DD7-40BB-A1B8-4E2AA1F9FDF2> >
Received on Tuesday, 15 March 2016 15:30:11 UTC