I want to create a collection of people in json-ld format but I need to keep some keys instead of using arrays so I tried this first:
{
"@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"
}
}
}
Testing it in the JSON-LD Playground everything looks fine and the N-Quads result show something as expected like this:
<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> .
Then I wanted to add a schema:knows property also keeping the keys and not using arrays like this:
{
"@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"
}
}
}
This time when I tested in the playground it return the following error:
{ "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" } } }
So what is an alternative to keep the keys and never use arrays or the correct way to use Index Maps?
Regards