这是对 JSON-LD 索引图的正确使用吗?
Is this a correct use of JSON-LD Index Maps?
我想创建一个 json-ld 格式的人物集合,但我需要保留一些键而不是使用数组,所以我首先尝试了这个:
{
"@context" : {
"@base" : "http://www.example.com/data/",
"@vocab" : "http://www.example.com/vocab#",
"name" : "schema:name",
"people" : {
"@container" : "@index",
"@id" : "people"
},
"schema" : "http://schema.org/"
},
"@id" : "http://www.example.com",
"people" : {
"person1" : {
"@id" : "people/person1",
"name" : "Person 1"
},
"person2" : {
"@id" : "people/person2",
"name" : "Person 2"
},
"person3" : {
"@id" : "people/person3",
"name" : "Person 3"
},
"person4" : {
"@id" : "people/person4",
"name" : "Person 4"
}
}
}
在 JSON-LD Playground 中对其进行测试,一切看起来都很好,N-Quads 结果显示如下所示:
<http://www.example.com/data/people/person1> <http://schema.org/name> "Person 1" .
<http://www.example.com/data/people/person2> <http://schema.org/name> "Person 2" .
<http://www.example.com/data/people/person3> <http://schema.org/name> "Person 3" .
<http://www.example.com/data/people/person4> <http://schema.org/name> "Person 4" .
<http://www.example.com> <http://www.example.com/vocab#people> <http://www.example.com/data/people/person1> .
<http://www.example.com> <http://www.example.com/vocab#people> <http://www.example.com/data/people/person2> .
<http://www.example.com> <http://www.example.com/vocab#people> <http://www.example.com/data/people/person3> .
<http://www.example.com> <http://www.example.com/vocab#people> <http://www.example.com/data/people/person4> .
然后我想添加一个 schema:knows 属性 也保留键而不使用这样的数组:
{
"@context" : {
"@base" : "http://www.example.com/data/",
"@vocab" : "http://www.example.com/vocab#",
"knows" : {
"@container" : "@index",
"@id" : "schema:knows",
"@type" : "@id"
},
"name" : "schema:name",
"people" : {
"@container" : "@index",
"@id" : "people"
},
"schema" : "http://schema.org/"
},
"@id" : "http://www.example.com",
"people" : {
"person1" : {
"@id" : "people/person1",
"knows" : {
"person2" : "people/person2",
"person3" : "people/person3"
},
"name" : "Person 1"
},
"person2" : {
"@id" : "people/person2",
"name" : "Person 2"
},
"person3" : {
"@id" : "people/person3",
"name" : "Person 3"
},
"person4" : {
"@id" : "people/person4",
"name" : "Person 4"
}
}
}
这次在操场上测试的时候return出现如下错误:
{ "name": "jsonld.SyntaxError", "message": "Invalid JSON-LD syntax;
conflicting @index property detected.", "details": { "code":
"conflicting indexes", "subject": { "@id":
"http://www.example.com/data/people/person2", "@index": "person2" } }
}
那么保留键而不使用数组的替代方法或使用索引映射的正确方法是什么?
此致
这是正确的。您在 jsonld.js (which I already reported). You can try to run the example in my playground or by using Gregg Kellogg's RDF distiller service 中发现了一个错误。两个 return 您期望的三元组。
我想创建一个 json-ld 格式的人物集合,但我需要保留一些键而不是使用数组,所以我首先尝试了这个:
{
"@context" : {
"@base" : "http://www.example.com/data/",
"@vocab" : "http://www.example.com/vocab#",
"name" : "schema:name",
"people" : {
"@container" : "@index",
"@id" : "people"
},
"schema" : "http://schema.org/"
},
"@id" : "http://www.example.com",
"people" : {
"person1" : {
"@id" : "people/person1",
"name" : "Person 1"
},
"person2" : {
"@id" : "people/person2",
"name" : "Person 2"
},
"person3" : {
"@id" : "people/person3",
"name" : "Person 3"
},
"person4" : {
"@id" : "people/person4",
"name" : "Person 4"
}
}
}
在 JSON-LD Playground 中对其进行测试,一切看起来都很好,N-Quads 结果显示如下所示:
<http://www.example.com/data/people/person1> <http://schema.org/name> "Person 1" .
<http://www.example.com/data/people/person2> <http://schema.org/name> "Person 2" .
<http://www.example.com/data/people/person3> <http://schema.org/name> "Person 3" .
<http://www.example.com/data/people/person4> <http://schema.org/name> "Person 4" .
<http://www.example.com> <http://www.example.com/vocab#people> <http://www.example.com/data/people/person1> .
<http://www.example.com> <http://www.example.com/vocab#people> <http://www.example.com/data/people/person2> .
<http://www.example.com> <http://www.example.com/vocab#people> <http://www.example.com/data/people/person3> .
<http://www.example.com> <http://www.example.com/vocab#people> <http://www.example.com/data/people/person4> .
然后我想添加一个 schema:knows 属性 也保留键而不使用这样的数组:
{
"@context" : {
"@base" : "http://www.example.com/data/",
"@vocab" : "http://www.example.com/vocab#",
"knows" : {
"@container" : "@index",
"@id" : "schema:knows",
"@type" : "@id"
},
"name" : "schema:name",
"people" : {
"@container" : "@index",
"@id" : "people"
},
"schema" : "http://schema.org/"
},
"@id" : "http://www.example.com",
"people" : {
"person1" : {
"@id" : "people/person1",
"knows" : {
"person2" : "people/person2",
"person3" : "people/person3"
},
"name" : "Person 1"
},
"person2" : {
"@id" : "people/person2",
"name" : "Person 2"
},
"person3" : {
"@id" : "people/person3",
"name" : "Person 3"
},
"person4" : {
"@id" : "people/person4",
"name" : "Person 4"
}
}
}
这次在操场上测试的时候return出现如下错误:
{ "name": "jsonld.SyntaxError", "message": "Invalid JSON-LD syntax; conflicting @index property detected.", "details": { "code": "conflicting indexes", "subject": { "@id": "http://www.example.com/data/people/person2", "@index": "person2" } } }
那么保留键而不使用数组的替代方法或使用索引映射的正确方法是什么?
此致
这是正确的。您在 jsonld.js (which I already reported). You can try to run the example in my playground or by using Gregg Kellogg's RDF distiller service 中发现了一个错误。两个 return 您期望的三元组。