json-ld-api
json-ld-api copied to clipboard
What to do with value entries outside value objects?
In my current implementation of the expansion algorithm, when the expanded node only contains value entries (i.e. @language or @direction entries), then it is dropped. In my interpretation of the JSON-LD syntax, this is more or less what is intended as the map is neither a node object nor a value object. This is also quite natural to do it this way with a typed implementation since node objects cannot include @language or @direction by construction.
I discovered that this is not what is described by the JSON-LD API document, where this doesn't seem to be really covered. It only covers the case where the map only contains a @language entry, in which case it is ignored:
If result is a map that contains only the entry
@language, return null.
More complex cases are not covered. In the playground, only the d map is dropped in the following example:
{
"http://a": {
"@id": "http://a",
"@language": "fr"
},
"http://b": {
"@id": "http://b",
"@language": "en",
"@direction": "ltr"
},
"http://c": {
"@id": "http://c",
"@direction": "ltr"
},
"http://d": {
"@language": "fr"
},
"http://e": {
"@language": "en",
"@direction": "ltr"
},
"http://f": {
"@direction": "ltr"
}
}
In my case, I drop d, e and f while removing the problematic entries in a, b and c. Is that a wrong interpretation of the expansion algorithm?
I consider this as an oversight; this section should have been updated when we added the @direction keyword. @gkellogg @dlongley WDYT?
Also, it seems that we have no test case for step 18 (the one quoted by @timothee-haudebourg). The proposed snippet is a good candidate for such a test.