JSON-LD 中的多个上下文
Multiple contexts in JSON-LD
如何在 JSON-OLD 中访问两个单独的人声,我可以使用 2 个@contexts 吗?
例如
{
"@context": {
"@vocab": "http://schema.org/",
"first_name": "givenName",
"last_name": "familyName
}
"@context": {
"@vocab": "http://our_own_schema.org/",
"Time": "inputTime"
}
}
您可以提供多个@context
。如果它们包含重复的术语,则使用最近定义的术语。 See examples 27 and 28。但是如果你想在同一个对象中混合词汇,这是行不通的。
要允许在同一对象中混合使用词汇,您可以在文档顶部的 @context
中定义所有词汇。每个词汇表都可以有一个前缀,这样你就可以使用 compact IRIs. One vocabulary can be the default one (without prefix).
默认词汇表:
"@context":
[
"http://schema.org/",
{"oos": "http://our_own_schema.org/"}
],
键 name
扩展为 http://schema.org/name
,
键 oos:name
扩展为 http://our_own_schema.org/name
.
没有默认词汇表:
"@context":
{
"schema": "http://schema.org/",
"oos": "http://our_own_schema.org/"
},
键name
将被忽略,
键 schema:name
扩展为 http://schema.org/name
,
键 oos:name
扩展为 http://our_own_schema.org/name
.
注意:始终可以使用 absolute IRIs 作为键。您不必在上下文中定义这些。
如何在 JSON-OLD 中访问两个单独的人声,我可以使用 2 个@contexts 吗? 例如
{
"@context": {
"@vocab": "http://schema.org/",
"first_name": "givenName",
"last_name": "familyName
}
"@context": {
"@vocab": "http://our_own_schema.org/",
"Time": "inputTime"
}
}
您可以提供多个@context
。如果它们包含重复的术语,则使用最近定义的术语。 See examples 27 and 28。但是如果你想在同一个对象中混合词汇,这是行不通的。
要允许在同一对象中混合使用词汇,您可以在文档顶部的 @context
中定义所有词汇。每个词汇表都可以有一个前缀,这样你就可以使用 compact IRIs. One vocabulary can be the default one (without prefix).
默认词汇表:
"@context": [ "http://schema.org/", {"oos": "http://our_own_schema.org/"} ],
键
name
扩展为http://schema.org/name
,
键oos:name
扩展为http://our_own_schema.org/name
.没有默认词汇表:
"@context": { "schema": "http://schema.org/", "oos": "http://our_own_schema.org/" },
键
name
将被忽略,
键schema:name
扩展为http://schema.org/name
,
键oos:name
扩展为http://our_own_schema.org/name
.
注意:始终可以使用 absolute IRIs 作为键。您不必在上下文中定义这些。