Skip to content
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

Extracting container tags in de-hashified form #58

Open
ships opened this issue Mar 13, 2023 · 2 comments
Open

Extracting container tags in de-hashified form #58

ships opened this issue Mar 13, 2023 · 2 comments
Labels
question Further information is requested

Comments

@ships
Copy link

ships commented Mar 13, 2023

Hi ruben! Thanks so much for this (and many other) jsonld libraries that are enabling my work.

In my use-case I would like to use this lib to parse a context remotely, then insert it into jsonld-serializer-ext, which relies on jsonld@8 library. Based on values passed around I would expect to be able to call parse() and then getContextRaw().

This generally works but causes runtime errors because of the containerToHash method; in parsing a context, the jsonld.js library expects the @container to point to an Array or string, but the normalizedRaw puts out values of form `'@container': { '@language': true}'

Is there a step I am missing to get the normalized / raw context back out of this parser as an object with the standard @container : Array | string?

The example i am working with is here. For example I get

steps: {
    '@id': 'http://purl.org/spar/pwo/hasStep',
    '@container': { '@id': true }
  },

out of the contextRaw. I see in #40 that you suggest this is for performance reasons, maybe i am just missing how to get back out of this form..! Thank you.

@rubensworks
Copy link
Owner

Is there a step I am missing to get the normalized / raw context back out of this parser as an object with the standard @container : Array | string?

Unfortunately this library doesn't support this yet. The raw context is just an internal representation structured for optimal performance, so it's not valid according to the JSON-LD context spec.
Serializing back to a valid context would be possible, but that would require changing the structure of things like @container.

@rubensworks rubensworks added the question Further information is requested label Mar 15, 2023
@ships
Copy link
Author

ships commented Mar 23, 2023

thanks Ruben! After reviewing this I have found a workaround by relying on some native behavior in jsonld.js that I call directly. I will track this issue in case the export becomes implemented in future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants