Re: Enforcing an array on @type/type

It’s supported in the working draft now. See https://github.com/w3c/json-ld-syntax/pull/74.

Gregg Kellogg

Sent from my iPad

> On Oct 22, 2018, at 12:42 PM, Adrian Pohl <pohl@hbz-nrw.de> wrote:
> 
> Hello,
> 
> for having homogeneous data to query and reuse we decided to always have an array with "@type" (aliased to "type") in our JSON-LD. (Mostly, there is only one "type" in our data but we also systematically use more than one in some places, see e.g. the example [record].)
> 
> Currently, we still generate the JSON-LD from N-Triples using a custom tool but we want to switch to using the JSON-LD [Java] library. However, it does not seem possible to enforce an array on "@type".
> 
> 1.) You can not use an object on "@type" directly in the context like this:
> 
> {
>  "@type": {
>    "@container": "@set"
>  }
> }
> 
> See also [example1] in the JSON-LD playground. looking at the spec, it obviously rules out using the @type keyword as a key in the context:
> 
> "A context definition must be a JSON object whose keys must either be terms, compact IRIs, absolute IRIs, or the keywords @language, @base, and @vocab."
> 
> 2.) This leaves the option to use "@container": "@set" on the term that is aliased to "@type":
> 
> {
>  "type": {
>    "@id": "@type",
>    "@container": "@set"
>  }
> }
> 
> But this also currently does not work, see [example2]. I can not directly see from the spec why this should not be possible but it seems like aliasing is only defined as a direct mapping of a term onto a keyword and does not allow an expanded term definition.
> 
> We would be happy if at least the second option would work. Maybe it could be taken into account for JSON-LD 1.1?
> 
> All the best
> Adrian
> 
> P.S.: My colleague Pascal has already opened a [question] on Stack Overflow for this.
> 
> [record] http://lobid.org/resources/HT019826954.json
> [Java] https://github.com/jsonld-java/jsonld-java
> [example1] http://tinyurl.com/ybc7d835
> [example2] http://tinyurl.com/y8e7wlmj
> [question] https://stackoverflow.com/questions/52877462/how-to-enforce-an-array-on-type-in-jsonld
> 

Received on Monday, 22 October 2018 16:00:39 UTC