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

Fix for BlankNode as NamedNode when parsing JSON-LD #555 #558

Closed
wants to merge 3 commits into from

Conversation

RinkeHoekstra
Copy link
Contributor

@RinkeHoekstra RinkeHoekstra commented Jul 19, 2022

The JSON-LD parser currently uses the JSON-LD flattening algorithm of jsonld.js. This algorithm assigns @id attributes to blank nodes, but the JSON-LD parser only creates a BlankNode when no @id is present.

This means that currently, the blank nodes in JSON-LD are interpreted as NamedNode, which is incorrect.

This pull request does the following:

  • Add a check to see whether the @id value starts with _:.
  • If it does, it is a BlankNode, otherwise it is a NamedNode.
  • If it is a blank node, strip it from the _: as this will be added by the instantiation of the BlankNode class.
  • Make sure to perform this check whenever a new object node is created (there were three separate checks in the code)

This fixes #555

Also raised an issue in rdf-canonize (digitalbazaar/rdf-canonize#45) to flag the problem that blank node identifiers generated by jsonld.js are not unique across loads (this is the cause of issue #405 )

@bourgeoa
Copy link
Contributor

bourgeoa commented Aug 23, 2022

@RinkeHoekstra CI fails. If I only add your first commit e0d332e it does not fail locally

I think you should only keep this one and make other PR for your last 2 commits that are not directly related so I can merge your PR.

@bourgeoa
Copy link
Contributor

resolved with 17052b6

@bourgeoa bourgeoa closed this Jan 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Turtle serializer shouldn't write blank nodes as <...>
2 participants