3
我有一個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"
}
}
}
,在運行時(該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"
}
}
}
base_context.jsonld
:
{
"foaf": "http://xmlns.com/foaf/0.1/",
"first_name": "foaf:givenName",
"last_name": "foaf:familyName",
"knows": "foaf:knows"
}
這可能嗎?
順便說一下,'MartyP'資源不應該在@context中。上下文僅用於將JSON鍵和值轉換爲URI。相反,'MartyP'對象應該完全位於'known'數組中。請試試[JSON-LD playgroud](http://json-ld.org/playground/)以獲取它的一個掛起。 – 2014-10-07 12:53:07