w3c / w3c/json-ld-api

value object with `"@type": "rdf:langString"`

Open
#682 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
106
Forks
40
PR merge metrics
No merged PRs in 30d

Description

Consider the following:

{
  "x:p": {
    "@value": "foo",
    "@type": "http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"
  }
}

It is currently a valid JSON-LD document, even though it corresponds to an invalid RDF graph (because a literal with datatype rdf:langString but no language tag is not allowed in the abstract data model.
In fact, this causes an ambiguity in the toRdf algorithm, which does not tell you what to do with this pathological case, and implementations diverge.

  • jsonld.js simply "eats" the datatype, turning it implicitly into (permalink)
  • sophia faithfully produces "foo"^^rdf:langString (permalink), but then refuses to parse the resulting n-quads (permalink)
  • PyLD raises an error

Proposed solution: we should refine the definition of value object to forbid @type to have value http://www.w3.org/1999/02/22-rdf-syntax-ns#langString (and, eventually, http://www.w3.org/1999/02/22-rdf-syntax-ns#dirLangString).
Accordingly, the Expand algorithm should raise an "invalid value object" error when it is lead to create such an object (e.g. via IRI expansion and/or type coercion).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the JSON-LD 1.1 value objects definition and the Expand algorithm referenced in the issue, then compare the jsonld.js, Sophia, and PyLD behaviors described. Done means the specification clearly forbids the invalid rdf:langString value object and defines the corresponding invalid value object error, including any decision about rdf:dirLangString.

Written by the indexing model from the issue text.

Assessment

Tech stack
json
Domain
documentation
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.