Maa*_*ten 4 semantic-web linked-data json-ld
我有一个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"
}
}
}
Run Code Online (Sandbox Code Playgroud)
现在,本文档的部分上下文是在运行时(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"
}
}
}
Run Code Online (Sandbox Code Playgroud)
base_context.jsonld:
{
"foaf": "http://xmlns.com/foaf/0.1/",
"first_name": "foaf:givenName",
"last_name": "foaf:familyName",
"knows": "foaf:knows"
}
Run Code Online (Sandbox Code Playgroud)
这可能吗?
每个@context实际上可以是多个对象(或URL),然后按照它们出现的顺序组合(这样就可以改变术语的含义 - 注意那里).
要做到这一点,您可以使用一个数组,您可以在其中混合本地和外部上下文.这是你的榜样
{
"@context":
[
"http://example.com/base_context.jsonld",
{
"@vocab": "http://example.com/"
}
]
}
Run Code Online (Sandbox Code Playgroud)
它在JSON-LD规范的第6.7节中描述.