我定义了一个具有多个上下文的jsonld文件。每个上下文定义一个具有相同名称的术语。当对jsonld文件执行压缩时,具有相同名称的所有字段都在相同的名称空间中。
例如,使用下面的文件
{
"@context": [
{
"name1": "http://example.org/name1/",
"id" : {
"@id" : "name:id",
"@type" : "xsd:string"
}
},
{
"name2": "http://example.org/name2/",
"identifier": {
"@id": "name2"
},
"id" : {
"@id" : "name2:id",
"@type" : "xsd:string"
}
}],
"@id": "http://example.org/1",
"id" : "id/1",
"identifier": {
"id" : "identifier/1"
}
}我在压缩后得到这个结果。
{
"@id" : "http://example.org/1",
"http://example.org/name2/" : {
"http://example.org/name2/id" : {
"@type" : "xsd:string",
"@value" : "identifier/1"
}
},
"http://example.org/name2/id" : {
"@type" : "xsd:string",
"@value" : "id/1"
}
}但我会期待这一点
{
"@id" : "http://example.org/1",
"http://example.org/name2/" : {
"http://example.org/name2/id" : {
"@type" : "xsd:string",
"@value" : "identifier/1"
}
},
"http://example.org/name1/id" : { <== here name1
"@type" : "xsd:string",
"@value" : "id/1"
}
}发布于 2017-10-22 05:35:22
上下文中定义的术语按顺序排列,最后遇到的上下文取胜。在这个例子中,我没有看到任何在压缩时使用不同术语的方法。但是,您可能希望看到JSON-LD1.1中的Scoped Contexts为您提供了更大的灵活性。
https://stackoverflow.com/questions/46824453
复制相似问题