w3c / json-ld-syntax

JSON-LD 1.1 Specification
https://w3c.github.io/json-ld-syntax/
Other
112 stars 22 forks source link

feature request: support `$schema` as an alias for `@context` #420

Closed pchampin closed 5 months ago

pchampin commented 11 months ago

More precisely, I suggest that JSON-LD processors do the following:

The rationale is the following:

Caveats: the proposed behavior might break some documents that already point to a "normal" JSON-Schema (i.e one that does not contain a @context key). We might want to add a special case for contexts loaded via "$schema", so that they don't raise an invalid default context in that case.

BigBlueHat commented 10 months ago

The confusion definitely needs solving, but horses and unicorns are different...despite their similarities.

BigBlueHat commented 10 months ago

It is, however, totally conceivable to create a more expressive context file which could potentially work as both--though I think we leave the key name as @context if that's it's current primary purpose. The Web of Things group mapped JSON Schema to RDF: https://www.w3.org/2019/wot/json-schema

It's possible to turn a context file into an actual JSON-LD document (and rather than the unique thing they are), and in that document more fully express vocabulary, schema, etc. I've seen it done a number of times (and ways...), but standardizing on an approach to that could be pretty epic. 😃

pchampin commented 10 months ago

@BigBlueHat

horses and unicorns are different...despite their similarities.

I totally agree that they are different, but schemas and context are also very complementary. When designing a JSON-LD context, we are making assumptions about how the instance data will be organized. When designing a JSON-Schema, we have an idea of the semantics of the attributes described by the schema...

I was aware of the WoT WG group you link to, but I had overlooked one of the use-cases they point to : Defining a JSON-LD context for data instances. While the technicalities are different from my proposal above, the general idea is the same : use the schema to convey the context that should be applied to the instance data. My proposal above would become something like that :

Would this be more acceptable? I admit that, although slightly more complicated, it is a cleaner solution.

gkellogg commented 5 months ago

This was discussed in a CG Meeting and it was decided to close the issue without prejudice.