Closed jazzyray closed 5 years ago
It seems to be an artifact of using @nest
with multiple values. @nest
is typically only used with a single object as a value, mostly for compatibility purposes, but the grammar allows an array of objects.
What is happening is that the algorithm adds properties from the first object to the containing object, and then when it accesses the second object, it finds that the @type
property already exists, so calls it a collision. The grammar allows an array of objects (dictionaries).
The error comes from step 13.4.2 of the Expansion Algorithm:
If result has already an expanded property member, a
colliding keywords
error has been detected and processing is aborted.
Hi Greg,
OK, I guess this is the spec. Thanks for letting me know the rationale.
However it would perhaps be a nice extension to allow @nest
on something like this?
So one could avoid blank nodes and predicates such as
_:b0 <https://starwars.org/vocabulary/people>
I can see that this might cause some additional complexity though and might not be at the top of everyone's wish list.
See -->
{
"@context": {
"@base": "https://starwars.org/resource/",
"@vocab": "https://starwars.org/vocabulary/",
"url": "@id",
"species": "@type"
},
"people": [
{
"name": "Luke SkyWalker",
"url": "human/1",
"species": "Human"
},
{
"name": "C-3PO",
"species": "Droid",
"url": "droid/2"
}
]
}
<https://starwars.org/resource/droid/2> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://starwars.org/vocabulary/Droid> .
<https://starwars.org/resource/droid/2> <https://starwars.org/vocabulary/name> "C-3PO" .
<https://starwars.org/resource/human/1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://starwars.org/vocabulary/Human> .
<https://starwars.org/resource/human/1> <https://starwars.org/vocabulary/name> "Luke SkyWalker" .
_:b0 <https://starwars.org/vocabulary/people> <https://starwars.org/resource/droid/2> .
_:b0 <https://starwars.org/vocabulary/people> <https://starwars.org/resource/human/1> .
I guess I’m not really sure what you want to do, the use of @nest
May not be what you think it’s for. You describe two different people, and @nest
would simply merge all the properties into a sing node, with two types, two names, and two species. It may be that you want to simply alias people to @graph
to have two top-level nodes. You’ll still have blank nodes, unless you give them each an identifier.
This "people": "@graph"
is exactly what I was looking for.
Thanks for pointing me towards it.
Hello,
Is there a reason for colliding keywords detected when using
@nest
in the following example:http://tinyurl.com/y6d9lw5j
Processing Mode: JSON-LD 1.1
Any pointers most appreciated. Jem