Re: json-ld and sparql

Hi Jean-Claude,

Try using the CONSTRUCT form of SPARQL and use Accept header to request results in JSON-LD.

prefix schema: <http://schema.org/>
construct where {
?p a schema:Place .
?p rdfs:label ?name .
?p geo:lat ?lat .
?p geo:long ?lon .
}
LIMIT 5

Regards,
John

On 15 Mar 2016, at 14:35, "Jean-Claude Moissinac" <jean-claude.moissinac@telecom-paristech.fr<mailto: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>

Received on Tuesday, 15 March 2016 15:54:21 UTC