jsonld.js icon indicating copy to clipboard operation
jsonld.js copied to clipboard

Forward slash in JSON key treated as error

Open jakubklimek opened this issue 1 year ago • 2 comments

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 avatar Nov 23 '23 07:11 jakubklimek

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
}

jakubklimek avatar Nov 23 '23 07:11 jakubklimek

@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

lemoustachiste avatar Nov 29 '23 13:11 lemoustachiste