Skip to content

Expanded containers. #292

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
davidlehn opened this issue Nov 6, 2019 · 3 comments
Closed

Expanded containers. #292

davidlehn opened this issue Nov 6, 2019 · 3 comments

Comments

@davidlehn
Copy link
Contributor

I'm not sure where best to track post-1.1 features. Please move or label this as appropriate. This comes from IRC and gitter.
https://gitter.im/json-ld/json-ld.org?at=5d852a8c2438b53a64e95467

The use case is wanting to perform compaction and have a uniform output data shape for easier processing. When using @language on some values, but not others, you can end up with a non-uniform output shape. Is there some trick with current features that would make a uniform compacted shape possible? Or is pre or post processing the preferred solution in such cases?

One solution would be to add @expand as a value for @container (potentially with other flags as well). When compacting, those values would always be expanded. (Would need to consider interaction with other features like language maps.)

Current input:

{
  "@context": {
    "p": {
      "@id": "ex:p"
    }
  },
  "p": [
    {
      "@value": "p-aa",
      "@language": "aa"
    },
    "p-bb"
  ]
}

Current compacted output (using input context) can be difficult to easily process:

{
  "@context": {
    "p": {
      "@id": "ex:p"
    }
  },
  "p": [
    {
      "@language": "aa",
      "@value": "p-aa"
    },
    "p-bb"
  ]
}

Possible container feature input:

{
  "@context": {
    "p": {
      "@id": "ex:p",
      "@container": "@expand"
    }
  },
  "p": [
    {
      "@value": "p-aa",
      "@language": "aa"
    },
    "p-bb"
  ]
}

Possible compacted output (using input context):

{
  "@context": {
    "p": {
      "@id": "ex:p",
      "@container": "@expand"
    }
  },
  "p": [
    {
      "@language": "aa",
      "@value": "p-aa"
    },
    {
      "@value": "p-bb"
    }
  ]
}
@gkellogg
Copy link
Member

gkellogg commented Nov 6, 2019

Language maps might make a more consistent output. We also allow @type: @none, which has that affect.

  • Added support for "@type": "@none" in a term definition to prevent value compaction.

@gkellogg
Copy link
Member

gkellogg commented Nov 6, 2019

This seems to be a duplicate of w3c/json-ld-api#33, which was merged in w3c/json-ld-api#63.

@davidlehn
Copy link
Contributor Author

So many exciting new 1.1 features I'm losing track! Original question was to do this without language maps. It does look like that "@type": "@none" feature works (in the distiller). Not yet supported in jsonld.js though.

Compaction context:

{
  "@context": {
    "@version": 1.1,
    "p": {
      "@id": "ex:p",
      "@type": "@none"
    }
  }
}

Output:

{
  "@context": {
    "@version": 1.1,
    "p": {
      "@id": "ex:p",
      "@type": "@none"
    }
  },
  "p": [
    {
      "@value": "p-aa",
      "@language": "aa"
    },
    {
      "@value": "p-bb"
    }
  ]
}

@andygreenegrass Does that look like what you were asking for?

I think this issue can be closed.

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

2 participants