Skip to content

Enable JSON-LD expansion on subjects (in addition to properties) #37

Description

@matthieu-fesselier

As we sometimes use the resource ids in URLs, we would like to use reduced ids to make it cleaner.
I expected the following code to work but I get an error. Am I doing something wrong here?

const base_context = {
  ...
  "collective":"https://api.happy-dev.fr/collectives/"
};

await solid.data.context.extend(base_context);
const resource = solid.data['collective:1']
console.log(`${await resource.name}`)

Activity

  1. RubenVerborgh commented on Sep 16, 2019

    @RubenVerborgh
    Member

    JSON-LD context expansion is currently not used for the base subject (directly after 'solid.data'), only for properties. It does indeed make sense to extend it to this case.

  2. changed the title [-]Cannot use reduced ids[/-] [+]Enable JSON-LD expansion on subjects (in addition to properties)[/+] on Sep 16, 2019
  3. rubensworks commented on Sep 16, 2019

    @rubensworks
    Contributor

    For reference when this will be implemented:
    It is important to use base expansion here, instead of the vocab expansion that is currently used for properties. This is because JSON-LD requires subjects (and objects) to be resolved against @base, and predicates against @vocab.

  4. matthieu-fesselier commented on Sep 17, 2019

    @matthieu-fesselier
    Author

    Great thanks!
    Any idea on how to reduce URLs on the meantime? Should we use the JSON-LD library?

  5. rubensworks commented on Sep 17, 2019

    @rubensworks
    Contributor

    Considering jsonld-context-parser is already added as a dependency, you could use that as follows:

    const ContextParser = require('jsonld-context-parser').ContextParser;
    const normalizedContext = await myParser.parse({
      ...
      "collective":"https://api.happy-dev.fr/collectives/"
    });
    const iri = ContextParser.expandTerm('collective:1', normalizedContext);
    const resource = solid.data[iri]
  6. matthieu-fesselier commented on Sep 17, 2019

    @matthieu-fesselier
    Author

    Thanks!
    When I get the type of this container: https://api.happy-dev.fr/collectives/
    I get the expanded field http://www.w3.org/ns/ldp#Container, but I expected ldp:Container. Is it the same problem here?

  7. RubenVerborgh commented on Sep 17, 2019

    @RubenVerborgh
    Member

    You get back a NamedNode; they are full URIs.

  8. matthieu-fesselier commented on Sep 18, 2019

    @matthieu-fesselier
    Author

    Ok, you mean that the NamedNode URIs are never compacted with the current context?

  9. RubenVerborgh commented on Sep 18, 2019

    @RubenVerborgh
    Member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureA new feature to be added

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions