Skip to content

@type as @container:@set? #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gkellogg opened this issue Jul 8, 2018 · 4 comments
Closed

@type as @container:@set? #34

gkellogg opened this issue Jul 8, 2018 · 4 comments
Assignees

Comments

@gkellogg
Copy link
Member

gkellogg commented Jul 8, 2018

The purpose of the @container:@set functionality (AFAIU) is to ensure that the output is consistent in shape. Thus if there can ever be multiple values, the structure is always an array.

There are two situations in which this functionality could be desirable but is currently not possible:

  1. @type As it's a keyword, we can only alias it (e.g. as type) but not define it to have @container:@set functionality. Meaning that there's a gotcha waiting to happen for ontologies that require or use multiple classes for a single resource instance. See playground
  2. @context Less useful, but @context will also compact to a single string/object when there might be multiple contexts. See playground

@context modifying itself seems particularly strange, but the inconsistency for @type seems solvable if the restrictions in its definition were loosened?

Original issue @type as @container:@set? #512.

(Edit: Note that the playground links demonstrate that these do not work as one might expect, due to the keyword definitions of @type and @context)

@dlongley
Copy link
Contributor

Seems like a useful feature to allow @container: @set for @type.

@gkellogg
Copy link
Member Author

We should consider allowing any keyword that can take multiple values, such as @graph, to allow it's container model to be updated. A use case outlined in #30 (comment) would do the following:

{
  "@context": {
    "dataset": {"@id": "@graph", "@container": ["@graph", "@id"]}
  },

It should allow the following as well:

{
  "@context": {
    "@graph": {"@container": ["@graph", "@id"]}
  },

This may need some extra sanity checking, as @list, or anything not including @graph would be prohibited.

@azaroth42
Copy link
Contributor

Resolution on WG call of 2018-08-17: @type (or an alias of it) can be set to be a @container (only), and if so it can have only the value of @set. This allows the use case of requiring the field to always be an array for consistency, even if there's only one value.

And secondly, that we will not change @context as the processing would be extremely convoluted for minimal value.

@azaroth42
Copy link
Contributor

Interestingly, someone proposed this be allowed back in 2012: json-ld/json-ld.org#80 (comment) 😀

@gkellogg gkellogg self-assigned this Aug 28, 2018
gkellogg added a commit to w3c/json-ld-api that referenced this issue Oct 1, 2018
…n alias in 1.1. Remains an error to redefine `@type` in 1.0.

For w3c/json-ld-syntax#34.
gkellogg added a commit that referenced this issue Oct 1, 2018
gkellogg added a commit to w3c/json-ld-api that referenced this issue Oct 3, 2018
…n alias in 1.1. Remains an error to redefine `@type` in 1.0.

For w3c/json-ld-syntax#34.
dr0i added a commit to dr0i/jsonld-java that referenced this issue Oct 27, 2018
dr0i added a commit to dr0i/jsonld-java that referenced this issue Oct 27, 2018
dr0i added a commit to dr0i/jsonld-java that referenced this issue Oct 27, 2018
dr0i added a commit to dr0i/jsonld-java that referenced this issue Oct 27, 2018
kazarena added a commit to piprate/json-gold that referenced this issue Feb 24, 2019
@azaroth42 azaroth42 added the satisfied Requirement Satisfied label Nov 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants