【发布时间】:2014-10-07 09:02:10
【问题描述】:
我有一个 JSON-LD 文档。
{
"@id": "VDWW1LL3MZ",
"first_name": "Vincent",
"last_name": "Willems",
"knows":["MartyP"],
"@context": {
"foaf": "http://xmlns.com/foaf/0.1/",
"first_name": "foaf:givenName",
"last_name": "foaf:familyName",
"knows": "foaf:knows",
"MartyP": {
"@id": "http://example.com/martyp",
"first_name": "Marty",
"last_name": "P"
}
}
}
现在,此文档的部分上下文是在运行时生成的(Marty P 对象),但 foaf 前缀定义是静态的,并且对每个文档重复。
如果我有 10 个前缀定义,将它们放在每个文档中会感觉很浪费。所以我想做类似的事情
generated document:
{
"@id": "VDWW1LL3MZ",
"first_name": "Vincent",
"last_name": "Willems",
"knows":["MartyP"],
"@context": {
"@extends": "http://example.com/base_context.jsonld",
"MartyP": {
"@id": "http://example.com/martyp",
"first_name": "Marty",
"last_name": "P"
}
}
}
base_context.jsonld:
{
"foaf": "http://xmlns.com/foaf/0.1/",
"first_name": "foaf:givenName",
"last_name": "foaf:familyName",
"knows": "foaf:knows"
}
这可能吗?
【问题讨论】:
-
顺便说一下,
MartyP资源不应该在@context 中。上下文仅用于将 JSON 键和值转换为 URI。相反,MartyP对象应该在knows数组中完整。请尝试使用JSON-LD playgroud 来掌握它。
标签: semantic-web linked-data json-ld