Re: Combining @id with @vocab / combining @graph with @included / JSON API compatibility

Thank you Pierre-Antoine

Le ven. 20 janv. 2023 à 09:02, Pierre-Antoine Champin <pierre-antoine@w3.org>
a écrit :

> Hi Thomas,
> On 17/01/2023 18:04, Thomas Francart wrote:
>
> Hello
>
> Considering the JSON-LD below, which combines @graph, @included and
> @vocab, I have 3 questions :
>
> 1. No rdf:type triple is produced with https://exemple.eu/entity_1 as
> subject. I intended the "id" attribute to be found in the context, as I
> marked the "id" key with "@type = @vocab". This works correctly with the
> type key.
> I understand this is because JSON-LD mandates @id to be IRIs or blank node
> identifiers. But why wouldn't it be possible to find the corresponding IRI
> in the @context ?
> I would like to do that so that the key is the same when I refer to
> "entity_1" in the "refers_to" key and when I describe "entity_1" in the
> "included" section.
>
> I can see why you would want that, but as a general rule, you can not
> override how keywords (@id, @type, @language...) interpret their values.
> Which means that attempting to do that should maybe raise a warning...
> (your "@type": "@vocab" in the definition of "id").
>
> I believe that this would open a dangerous pandora box (imagine replacing
> "@type": "@vocab" with "@type": "xsd:string" -- what would that mean?).
>
The goal is to be able to have the same (synctactic) id as an attribute
value in the data part, and as an id in the included part.
The alternative I am considering for this is to use an @base and simply use
relative URIs instead of trying to shorten them.


>
> 2. When combining @graph with @included, the triples from the @graph are
> put in an anonymous graph instead of the default graph. Triples from
> the @included section are put in the default graph (if I workaround the
> first issue by using an explicit IRI). I find that counter intuitive. The
> spec reads "*When a JSON-LD document's top-level structure is a map that
> contains no other keys than @graph and optionally @context (...), @graph is
> considered to express the otherwise implicit default graph*", but I
> suggest to change it to "*...contains no other keys than @graph and
> @included...*"
>
> Maybe there is another way to have the data+included structure at the
> top-most level while maintaining a single default graph ?
>
> easy: alias "graph" to "@included" instead of "@graph" :)
>

Great ! I hadn't thought about having 2 @included (mapped to 2 different
keys) at the same level.

Thanks
Thomas


>
> 3. This is done in an attempt to mimic the JSON API (jsonapi.org)
> structure while keeping JSON-LD compatibility. Do you know of other
> attempts to do so, or is there some kind of default "JSONAPI to JSON-LD"
> @context or something similar ?
>
> I have a vague recollection of somebody mentioning that while the WG was
> working on the 1.1 specifications, but don't remember who that was. Maybe
> Benjamin?
>
>   pa
>
>
> Thanks !
> Thomas
>
>
> ```
> {
>   "@context": {
>
>     "id": {
>       "@id": "@id",
>       "@type":"@vocab"
>     },
>
>     "type": {
>       "@id": "rdf:type",
>       "@type": "@vocab"
>     },
>
>     "refers_to": {
>       "@id": "https://exemple.eu/ontology#refers_to",
>       "@type": "@vocab"
>     },
>
>     "data": "@graph",
>     "included": "@included",
>
>     "entity_1": "https://exemple.eu/entity_1",
>
>     "Test" : "https://exemple.eu/ontology#Test"
>   },
>
>
>   "data": [
>     {
>       "id": "https://exemple.eu",
>       "type": "Test",
>       "refers_to": "entity_1"
>     }
>   ],
>
>   "included" : [
>     {
>       "id": "entity_1",
>       "type": "Test"
>     }
>   ]
> }
> ```
>
> --
>
> *Thomas Francart* -* SPARNA*
> Web de *données* | Architecture de l'*information* | Accès aux
> *connaissances*
> blog : blog.sparna.fr, site : sparna.fr, linkedin :
> fr.linkedin.com/in/thomasfrancart
> tel :  +33 (0)6.71.11.25.97, skype : francartthomas
>
>

-- 

*Thomas Francart* -* SPARNA*
Web de *données* | Architecture de l'*information* | Accès aux
*connaissances*
blog : blog.sparna.fr, site : sparna.fr, linkedin :
fr.linkedin.com/in/thomasfrancart
tel :  +33 (0)6.71.11.25.97, skype : francartthomas

Received on Friday, 20 January 2023 08:54:04 UTC