digitalbazaar / jsonld.js

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

Forward slash in JSON key treated as error #543

Open jakubklimek opened 7 months ago

jakubklimek commented 7 months ago

A forward slash in JSON key like this:

{
  "@context": {
    "@version": 1.1,
    "a/b": "https://a"
  }
}

is treated as bad syntax: jsonld.SyntaxError: Invalid JSON-LD syntax; term in form of IRI must expand to definition. However, forward slash is perfectly valid in JSON. Where does this syntax error come from?

{
  "@context": {
    "@version": 1.1,
    "a_b": "https://a"
  }
}

is OK.

jakubklimek commented 7 months ago

However, Apache Jena riot also reports this as invalid:

ERROR org.apache.jena.riot - A local context contains a term that has an invalid or missing IRI mapping [code=INVALID_IRI_MAPPING].

when used like this:

{
  "@context": {
    "@version": 1.1,
    "a/b": "https://a"
  },
  "@id": "https://id",
  "a/b": 2
}
lemoustachiste commented 7 months ago

@jakubklimek your issue is not too far from the one I was having here: https://github.com/digitalbazaar/jsonld.js/issues/542. Maybe it can help