如何在JSON-LD中访问两个单独的词汇,我可以使用2个@contexts吗? e.g。
{
"@context": {
"@vocab": "http://schema.org/",
"first_name": "givenName",
"last_name": "familyName
}
"@context": {
"@vocab": "http://our_own_schema.org/",
"Time": "inputTime"
}
}
答案 0 :(得分:3)
您可以提供多个@context
。如果它们包含重复的术语,则使用最近定义的术语。 See examples 27 and 28。但是如果你想在同一个对象中混合词汇表,这是行不通的。
要允许在同一对象中混合词汇表,您可以在文档顶部的@context
中定义所有词汇表。每个词汇表都可以有一个前缀,允许您使用compact IRIs。一个词汇可以是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作为键。您不必在上下文中定义它们。