basilapi / basil

Building Apis SImpLy from sparql endpoints
http://basil.kmi.open.ac.uk
24 stars 5 forks source link

serialization doesn't break out type/value #132

Open justin2004 opened 10 months ago

justin2004 commented 10 months ago
$ cat /tmp/q2.rq 
PREFIX wds: <http://www.wikidata.org/entity/statement/>
select *                 
where {
  # wds:Q23-21309B07-59CA-4703-A191-D8CD4E7B3FBF ?p ?o .
wds:Q183-a03c757b-464a-b91f-f37f-b2207b057a66 ?p ?o .
}

curl -u USER:PASS -X PUT "http://localhost:8080/basil" -H "X-Basil-Endpoint: https://query.wikidata.org/sparql" -T /tmp/q2.rq

$ curl 'http://localhost:8080/basil/qxw322338379/api.json' | jq .       
{                                                                                                                                              
  "vars": [                                                            
    "p",                                                                                                                                       
    "o"                                                                
  ],       
  "items": [             
    {                                                                                                                                          
      "p": "http://wikiba.se/ontology#rank",                                                                                                   
      "o": "http://wikiba.se/ontology#NormalRank"
    },
    {
      "p": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
      "o": "http://wikiba.se/ontology#BestRank"
    },
    {
      "p": "http://www.wikidata.org/prop/statement/P8988",
      "o": "osm&id=276"
    }
  ]
}

while jena (and graphDB, etc.) does this:

$ ~/Downloads/apache-jena-4.10.0/bin/rsparql --results=json --service https://query.wikidata.org/sparql --query /tmp/q2.rq 
{ "head": {
    "vars": [ "p" , "o" ]
  } ,
  "results": {
    "bindings": [
      { 
        "p": { "type": "uri" , "value": "http://wikiba.se/ontology#rank" } ,
        "o": { "type": "uri" , "value": "http://wikiba.se/ontology#NormalRank" }
      } ,
      { 
        "p": { "type": "uri" , "value": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" } ,
        "o": { "type": "uri" , "value": "http://wikiba.se/ontology#BestRank" }
      } ,
      { 
        "p": { "type": "uri" , "value": "http://www.wikidata.org/prop/statement/P8988" } ,
        "o": { "type": "literal" , "value": "osm&id=276" }
      }
    ]
  }
}

the way basil currently does it it makes it harder to just get the value. e.g.

{ ... "some_number":"1029^^http://www.w3.org/2001/XMLSchema#integer" ... }

while jena does:

        "some_number" : {
          "datatype" : "http://www.w3.org/2001/XMLSchema#integer",
          "type" : "literal",
          "value" : "1029"
        }