digitalbazaar / jsonld.js

A JSON-LD Processor and API implementation in JavaScript
https://json-ld.org/
Other
1.66k stars 195 forks source link

jsonld.SyntaxError for JSON context key containing "/" character #426

Open pawe3kaleta opened 3 years ago

pawe3kaleta commented 3 years ago

I'm getting the error (issue confirmed in https://json-ld.org/playground/): jsonld.SyntaxError: Invalid JSON-LD syntax; term in form of IRI must expand to definition.

for the following JSON document:

{
  "@context":{
    "my": "http://my.example.com",
    "a": "my:arg1",
    "b": "my:arg2",
    "b/a": "my:result"
  },
  "a": 2,
  "b": 4,
  "b/a": 2
}

The issue seems to be related to the field "b/a", which is valid JSON property name and it's not in a form of IRI.

gkellogg commented 3 years ago

It is in the form of a Relative IRI Reference, which would expand to an IRI. Not all JSON properties can be treated as terms.

lemoustachiste commented 3 years ago

Hi,

I have a similar error that arose today with a context that's been online for ages (2016). I have updated jsonld library from 1.8.1 to 5.2.0 and now it fails with that specific context which has a property defined as such:

"image:signature": {
   "@id": "bc:image:signature"
}

From this context: https://www.blockcerts.org/schema/1.2/context.json

and then in the credential document:

"image:signature": "data:image/png;base64,iVBORw0K..."

This error comes up when normalizing the document, but was not present in the older version of jsonld.

I understand this is invalid jsonld syntax, but I am wondering how I could bypass the error? I do not wish to remain with an older version of jsonld, but at the same time I have no way of knowing how many credentials were issued and are being verified on this version 1.2 of Blockcerts.

Thanks for your help