Description
According to Section 9. JSON-LD Grammar of the syntax document:
the term MUST NOT be an empty string ("") as not all programming languages are able to handle empty JSON keys
However:
- there is no step in the Context Processing algorithms for detecting empty term definitions,
- there is no test for it in the test-suite,
- implementations are handling this very heterogeneously (see below).
Consider the following example:
{
"@context": {
"": "http://example.org/"
},
"": "foo",
":bar": "baz"
}
- pyld and jsonld.js reject it with an error
- rdflib-jsonld accepts it and hallily expands both properties
- the Ruby distiller accepts it, expands "", but ignores ":bar".
For the record, this "blind spot" of the test-suite and algotithms dates back to JSON-LD 1.0.
What made me realize that (and makes me think this is a problem we should probably address) is that two contexts in prefixcommons' registry (mentionned by @hsolbrig in w3c/json-ld-syntax#329) have a term definition for the empty string, which makes them unusable with pyld or jsonld.js. Apparently, this went unnoticed because they are mostly using rdflib-jsonld...
I know it is late (too late?) to fix it, but I think the spec should be more explicit about how to handle a term definition when the term is the empty string (""
). Rejecting it seems consistent with the grammar. And a test should therefore be added.