【发布时间】:2018-09-01 09:25:32
【问题描述】:
所以我有一个预定义的本体和一个现有的 JSON 服务(两次都读作“不能更改那里的现有内容”)返回类似于以下 JSON 的内容:
{
"propA": "someResource",
"propB": "otherResource"
}
我想通过添加(我无法更改现有属性,但可以添加新属性)上下文定义来将该输出转换为 JSON-LD。在第一步中,我添加了这样的默认上下文:
"@context": {
"@vocab": "https://example.org/",
"propA": { "@type": "@vocab" },
"propB": { "@type": "@vocab" }
},
"@id": "https://example.org/blub",
这会将两个资源映射到@vocab (playground) 给出的命名空间。
<https://example.org/blub> <https://example.org/propA> <https://example.org/someResource> .
<https://example.org/blub> <https://example.org/propB> <https://example.org/otherResource> .
但是,两个引用的资源都属于两个不同的命名空间。所以我需要一些上下文,映射到以下内容:
<https://example.org/blub> <https://example.org/propA> <https://foo.com/someResource> .
<https://example.org/blub> <https://example.org/propB> <https://bar.com/otherResource> .
我在某处找到了hack using @base,但这只是一种解决方法,如果您需要一个额外的命名空间而不是多个命名空间。
那么当我需要两个以上的属性时,如何为不同的属性定义单独的命名空间前缀?
【问题讨论】:
标签: namespaces json-ld