Description
Given the various needs outlined in issues #84, #133, #159 and #195, it seems there may be a general need for noisy JSON to work as JSON-LD. While not ideal, it may be required for zero-edits.
This is a proposal to add a keyword, tentatively called @annotation
. It is only to be used in a context definition, and signals to the processor to skip a part of the JSON but continue recursive processing.
For example, it could be used to provide any kind of application-specific index-objects, like this:
{
"@context": {
"author": {"@id": "http://schema.org/author", "@container": "@annotation"}
},
"@id": "http://example.org/article",
"author": {
"regular": {"@id": "http://example.org/person/1"},
"guest": {"@id": "http://example.org/guest/cd24f329aa"}
}
}
The publisher has here decided that authors are to be accessed by some property (here some kind of role), which is not to be exposed as information (interpretable as RDF). To do this, the above shape has an injected artificial object between the author property and the authors, which is to be ignored. Thus, semantically, the above means exactly the same as:
{
"@context": {
"author": {"@id": "http://schema.org/author", "@container": "@annotation"}
},
"@id": "http://example.org/article",
"author": [
{"@id": "http://example.org/person/1"},
{"@id": "http://example.org/guest/cd24f329aa"}
]
}
The role information itself could of course be included in the information about the author, or in associated account data. In fact, this mechanism enables publishers to experiment with many kinds of special container algorithms (such as the before suggested @id
maps or generalized property maps for language, timestamps, etc.), which may in the future be part of JSON-LD. (At which time the context, and only that, could be updated with such newly supported container options.) And since objects-as-maps is a fairly common occurrence in JSON in the wild, this annotation mechanism may ease adoption in general.
The @annotation
keyword could also be used as the @id
for a term (i.e. again only in the context). If used so, the term itself would be ignored (and thus any linkage), but its object value could be processed, just as if it had been a top level object within a @graph
array. This may be a separate proposal.
A downside of this proposal is that the shape of compact JSON-LD becomes harder to immediately understand, since "faux" keys may pop up in unexpected places. The upshot is that any context using the annotation keyword can immediately be categorized as being for application-specific, idiosyncratic JSON. This lets consumers know that such JSON cannot be automatically created using compaction by itself, but has been composed by some other process. (This somewhat akin to RDFa in that the JSON syntax can be treated as a carrier with parts picked out as semantically relevant. Also compare this to GRDDL, replacing XML with JSON and XSLT with just the JSON-LD context.)
If these annotations must survive expansion, an intermediate object with only an @annotation
key reasonably have to be put into the expanded form. (Similar in shape to @list
objects.) There should be a flag to control if annotations are to be preserved (default being false
).