w3c / w3c/json-ld-syntax

Type coercion using xsd equivalents for native JSON datatypes leads to unexpected results

Open
#464 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
139
Forks
23
PR merge metrics
No merged PRs in 30d

Description

Input:

{
  "@context": {"foo": {"@id": "http://foo.example", "@type": "http://www.w3.org/2001/XMLSchema#boolean"}},
  "foo": true
}

Compacted against:

{
  "@context": {"foo": {"@id": "http://foo.example"}},
}

Results in:

{
  "@context": {"foo": {"@id": "http://foo.example"}},
  "foo": {
    "@type": "http://www.w3.org/2001/XMLSchema#boolean",
    "@value": true
  }
}

There might be an extremely fine semantic distinction here, but isn't {"@value": true} supposed to be semantically equivalent to {"@value": true, "@type": "http://www.w3.org/2001/XMLSchema#boolean"}? I understand that "true" can be coerced to a boolean, but true is already a boolean. There seems to be a disconnect between the native datatype and the @type, where native JSON datatypes have an implicit @type corresponding to xsd, but explicitly applying this type can do weird things with compaction depending on whether or not your context includes the @type in the term definition.

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 input, compacted context, and result shown in the issue; compare native JSON boolean handling with explicit xsd:boolean typing. Done means resolving whether these forms are semantically equivalent and agreeing on the expected compaction behavior for the JSON-LD 1.1 specification.

Written by the indexing model from the issue text.

Assessment

Tech stack
json
Domain
documentation
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.