我已经将一些JSON-ld转换为RDF,但是它似乎没有像我预期的那样产生带有主题的RDF。
因此,我的JSON-ld如下所示:
{
"@context":{
"personid":"http://schema.org/id",
"hasUpdateType":"http://schema.org/updateType"
},
"@type":"http://schema.org/Person",
"personid":"123456",
"hasUpdateType":{
"@type":"updateType",
"updateType":"Full"
}
}生成的RDF是
_:b0 <http://schema.org/id> "123456" .
_:b0 <http://schema.org/updateType> _:b1 .
_:b0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Person> .然而,我期望的是这样的东西(语法不正确,只是粗略地显示):
person hasUpdatetype Full我的json-ld是错的吗?
为了完成从json-ld到rdf的转换,我使用了这个库https://github.com/digitalbazaar/jsonld.js中的toRDF()
任何帮助都将不胜感激。
谢谢。
发布于 2020-01-18 05:22:39
您需要使用@id (或别名)来定义节点对象的主题。您可以在上下文中将"persondid“定义为@id。
您定义了"hasUpdateTime“来扩展为"schema:updateTime",因此扩展后的RDF应该使用"http://schema.org/updateType”作为谓词。如果您希望该值是与"Full“关联的单个URI,请在"hasUpdateType”上使用类型强制。下面这样的代码可能更接近你想要的。
{
"@context":{
"@base": "http://example.com/",
"personid":"@id",
"hasUpdateType": {"@id": "http://schema.org/updateType", "@type": "@id"}
},
"@type":"http://schema.org/Person",
"personid":"123456",
"hasUpdateType":"Full"
}这将为您提供以下三元组:
<http://example.com/123456> <http://schema.org/updateType> <http://example.com/Full> .
<http://example.com/123456> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Person> .https://stackoverflow.com/questions/59770597
复制相似问题