I don't think anyone would legitimately set @container to the empty array, I can't imagine why you would. I can see it getting emitted by JSON serialisation libraries for null or absent.
Reading the spec I'm reasonably convinced that this should raise an error. But the test suite doesn't have cases for it, and it seems to work on the JSON-LD Playground/jsonld.js.
If folks agree with my interpretation I can send in a few test cases.
Empty @container on a regular term
Given an input of:
{
"@context": {
"term": {"@id": "http://example.com/term", "@container": []}
},
"term": "http://example.com/test#example"
}
In step 19 of Create Term Definition:
If value contains the @container:
19.1) Initialize container to the value associated with the @container, which MUST be either @graph, @id, @index, @language, @list, @set, @type, or an array containing exactly any one of those keywords, an array containing @graph and either @id or @index optionally including @set, or an array containing a combination of @set and any of @index, @graph, @id, @type, @language in any order. Otherwise, an invalid container mapping has been detected and processing is aborted.
(It may also be nice to reword 19.1 because that sentence is a lot. Splitting it out into its own bullets may make it easier to follow. One other thing I'm not sure about is whether the order for what is in the array is relevant. It's explicitly called out in case it contains @set. For the other cases that would seem to suggest the order in which we spell them out is relevant?)
Since the empty array doesn't satisfy the requirements imposed on array, I would expect this to fail. We don't have a test for this, and the JSON-LD playground expands it to:
[
{
"http://example.com/term": [
{
"@value": "http://example.com/test#example"
}
]
}
]
Empty @container on an @reverse term
I think we have a similar case with @reverse and the empty @container.
Given an input of:
{
"@context":{
"term":{"@reverse":"http://example.com/term","@container":[]}
},
"term":{}
}
In step 13 of Create Term Definition:
If value contains the entry @reverse:
13.5) If value contains an @container entry, set the container mapping of definition to an array containing its value; if its value is neither @set, nor @index, nor null, an invalid reverse property error has been detected (reverse properties only support set- and index-containers) and processing is aborted.
Here I also think we should do the value check first, before the arrayification. Turning it into the array is a bit pointless if it doesn't have a valid value.
However, we lack a test for this too. In the case of the JSON-LD Playground, it expands to:
[
{
"@reverse": {
"http://example.com/term": [
{}
]
}
}
]
I don't think anyone would legitimately set
@containerto the empty array, I can't imagine why you would. I can see it getting emitted by JSON serialisation libraries for null or absent.Reading the spec I'm reasonably convinced that this should raise an error. But the test suite doesn't have cases for it, and it seems to work on the JSON-LD Playground/jsonld.js.
If folks agree with my interpretation I can send in a few test cases.
Empty
@containeron a regular termGiven an input of:
{ "@context": { "term": {"@id": "http://example.com/term", "@container": []} }, "term": "http://example.com/test#example" }In step 19 of Create Term Definition:
(It may also be nice to reword 19.1 because that sentence is a lot. Splitting it out into its own bullets may make it easier to follow. One other thing I'm not sure about is whether the order for what is in the array is relevant. It's explicitly called out in case it contains
@set. For the other cases that would seem to suggest the order in which we spell them out is relevant?)Since the empty array doesn't satisfy the requirements imposed on array, I would expect this to fail. We don't have a test for this, and the JSON-LD playground expands it to:
[ { "http://example.com/term": [ { "@value": "http://example.com/test#example" } ] } ]Empty
@containeron an@reversetermI think we have a similar case with
@reverseand the empty@container.Given an input of:
{ "@context":{ "term":{"@reverse":"http://example.com/term","@container":[]} }, "term":{} }In step 13 of Create Term Definition:
Here I also think we should do the value check first, before the arrayification. Turning it into the array is a bit pointless if it doesn't have a valid value.
However, we lack a test for this too. In the case of the JSON-LD Playground, it expands to:
[ { "@reverse": { "http://example.com/term": [ {} ] } } ]