如何在JSON-LD中返回SPARQL结果?
在 JSON- LD ,最好与标准化JSON格式保持一致?可以为每个查询或仅针对某些查询类型返回JSON-LD吗?
What is a good way to return SPARQL query results in JSON-LD, preferably staying close to the standardized JSON format? Can JSON-LD be returned for every query or only for certain query types?
以JSON格式(即不进行JSON-LD扩展)的SPARQL查询结果的示例:
An example of a SPARQL query result in JSON format (i.e., without JSON-LD enrichment):
{
"head": {"vars": ["s", "p", "o" ]},
"results": {
"bindings": [
{
"s": {
"type":"uri",
"value":"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
},
"p": {
"type":"uri",
"value":"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
},
"o": {
"type":"uri",
"value":"http://www.w3.org/1999/02/22-rdf-syntax-ns#Property"
}
}
]
}
}
JSON-LD本质上是RDF图的序列化格式,因此您可以立即将其用于任何RDF图的SPARQL查询结果(即,即任何CONSTRUCT或DESCRIBE查询的结果).
JSON-LD is a serialization format for, essentially, RDF graphs, so you can immediately use it for any SPARQL query result that is an RDF graph (that is, the result of any CONSTRUCT or DESCRIBE query).
如果您正在寻找序列化变量绑定结果(即SPARQL SELECT查询的结果)的格式,则应使用
If you are looking for a format to serialize a variable binding result (that is, the result of a SPARQL SELECT query), you should be using the SPARQL 1.1 Query Results JSON (SPARQL/JSON) format. This is not JSON-LD but it a JSON format specifically designed to serialize SPARQL query results.