SPARQL查询访问JSON-LD数组内部

时间:2017-02-01 19:49:32

标签: sparql json-ld

这是我的JSON-LD:

"locationCreated": {
"@type": "Place",
"@id": "http://test.fr/city/pacific-grove",
"geo": {
      "@type": "GeoCoordinates",
      "@id": "http://test.fr/city/pacific-grove/geo",
      "latitude": "36.6177374",
      "longitude": "-121.9166215"
    },
    "name": "Pacific Grove",
    "alternateName": "Pacific Grove, CA, USA"
  }

我想得到latitude&使用SPARQL的longitude值。实际上,当我进行查询时,我只能访问"http://test.fr/city/pacific-grove"的URI locationCreated

SPARQL查询:

prefix schema: <http://schema.org/> 
select ?locationCreated 
where { 
?x schema:locationCreated ?locationCreated
} 
LIMIT 100

感谢您的回答。

1 个答案:

答案 0 :(得分:2)

这应该适用于您的样本数据:

prefix schema: <http://schema.org/> 
select ?locationCreated ?lat ?long 
where { 
  ?x schema:locationCreated ?locationCreated .
  ?locationCreated schema:geo ?geoData .
  ?geoData schema:latitude ?lat .
  ?geoData schema:longitude ?long .
} 
LIMIT 100