scoped contexts
.
{
"@context": {
"@version": 1.1,
"@vocab": "https://example.org/",
"propA": { "@type": "@id", "@context": { "@base": "https://foo.com/"} },
"propB": { "@type": "@id", "@context": { "@base": "https://bar.com/"} }
},
"@id": "https://example.org/blub",
"propA": "someResource",
"propB": "otherResource"
}
有两件事需要注意:
-
"@version": 1.1
这是至关重要的。这告诉兼容处理器使用JSON-ld1.1规则集。
-
然后我们可以将每个属性放在一个单独的上下文中,并更改
@base
在这里。
this (dev) playground example
:
<https://example.org/blub> <https://example.org/propA> <https://foo.com/someResource> .
<https://example.org/blub> <https://example.org/propB> <https://bar.com/otherResource> .
:我们甚至可以通过设置
@type
到
@vocab
@声带
在作用域上下文中而不是
@底座
{
"@context": {
"@version": 1.1,
"@vocab": "https://example.org/",
"propA": {
"@type": "@vocab",
"@context": {
"@vocab": "http://foo.com/",
"abc": "http://bar.com/abc",
"xyz": "http://baz.com/xyz"
}
}
},
"@id": "https://example.org/blub"
}
现在取决于
propA
使用不同的名称空间(
play with it
):
"abc" -> <https://example.org/blub> <https://example.org/propA> <http://bar.com/abc> .
"xyz" -> <https://example.org/blub> <https://example.org/propA> <http://baz.com/xyz> .
"mnl" -> <https://example.org/blub> <https://example.org/propA> <http://foo.com/mnl> .