JSON query results: Allows "typed-literal" term type

Allows to parse e.g. Virtuoso query results
pull/216/head
Tpt 3 years ago
parent 9c06f7f097
commit 710a76b9cc
  1. 2
      lib/sparesults/src/json.rs
  2. 10
      server/src/main.rs
  3. 5
      testsuite/oxigraph-tests/sparql-results/manifest.ttl
  4. 16
      testsuite/oxigraph-tests/sparql-results/typed_literal.srj

@ -316,7 +316,7 @@ impl<R: BufRead> JsonSolutionsReader<R> {
match s { match s {
"uri" => t = Some(Type::Uri), "uri" => t = Some(Type::Uri),
"bnode" => t = Some(Type::BNode), "bnode" => t = Some(Type::BNode),
"literal" => t = Some(Type::Literal), "literal" | "typed-literal" => t = Some(Type::Literal),
#[cfg(feature = "rdf-star")] #[cfg(feature = "rdf-star")]
"triple" => t = Some(Type::Triple), "triple" => t = Some(Type::Triple),
_ => { _ => {

@ -1293,13 +1293,21 @@ mod tests {
} }
#[test] #[test]
fn post_federated_query() { fn post_federated_query_wikidata() {
let request = Request::builder(Method::POST, "http://localhost/query".parse().unwrap()) let request = Request::builder(Method::POST, "http://localhost/query".parse().unwrap())
.with_header(HeaderName::CONTENT_TYPE, "application/sparql-query") .with_header(HeaderName::CONTENT_TYPE, "application/sparql-query")
.unwrap().with_body("SELECT * WHERE { SERVICE <https://query.wikidata.org/sparql> { <https://en.wikipedia.org/wiki/Paris> ?p ?o } }"); .unwrap().with_body("SELECT * WHERE { SERVICE <https://query.wikidata.org/sparql> { <https://en.wikipedia.org/wiki/Paris> ?p ?o } }");
ServerTest::new().test_status(request, Status::OK) ServerTest::new().test_status(request, Status::OK)
} }
#[test]
fn post_federated_query_dbpedia() {
let request = Request::builder(Method::POST, "http://localhost/query".parse().unwrap())
.with_header(HeaderName::CONTENT_TYPE, "application/sparql-query")
.unwrap().with_body("SELECT * WHERE { SERVICE <https://dbpedia.org/sparql> { <http://dbpedia.org/resource/Paris> ?p ?o } }");
ServerTest::new().test_status(request, Status::OK)
}
#[test] #[test]
fn post_update() { fn post_update() {
let request = Request::builder(Method::POST, "http://localhost/update".parse().unwrap()) let request = Request::builder(Method::POST, "http://localhost/update".parse().unwrap())

@ -13,6 +13,7 @@
:results_tsv_duplicated_variables :results_tsv_duplicated_variables
:results_json_ignored_keys :results_json_ignored_keys
:results_xml_ignored_keys :results_xml_ignored_keys
:results_json_typed_literal
) . ) .
:results_json_duplicated_variables rdf:type ox:NegativeJsonResultsSyntaxTest ; :results_json_duplicated_variables rdf:type ox:NegativeJsonResultsSyntaxTest ;
@ -34,3 +35,7 @@
:results_xml_ignored_keys rdf:type ox:PositiveXmlResultsSyntaxTest ; :results_xml_ignored_keys rdf:type ox:PositiveXmlResultsSyntaxTest ;
mf:name "Ignore unknown attributes on tags" ; mf:name "Ignore unknown attributes on tags" ;
mf:action <ignored_keys.srx> . mf:action <ignored_keys.srx> .
:results_json_typed_literal rdf:type ox:PositiveJsonResultsSyntaxTest ;
mf:name "typed-literal term type is allowed" ;
mf:action <typed_literal.srj> .

@ -0,0 +1,16 @@
{
"head": {
"vars": ["s"]
},
"results": {
"bindings": [
{
"s": {
"type": "typed-literal",
"value": "foo",
"datatype": "http://example.com/dt"
}
}
]
}
}
Loading…
Cancel
Save