w3c / w3c/json-ld-api

What to do with value entries outside value objects?

Open
#535 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

ErratumRaised spec:bug spec:substantive substantive:class 3 test:needs tests
Dominant language
HTML
Stars
106
Forks
40
PR merge metrics
No merged PRs in 30d

Description

In my current implementation of the expansion algorithm, when the expanded node only contains value entries (i.e. @language or @direction entries), then it is dropped. In my interpretation of the JSON-LD syntax, this is more or less what is intended as the map is neither a node object nor a value object. This is also quite natural to do it this way with a typed implementation since node objects cannot include @language or @direction by construction.

I discovered that this is not what is described by the JSON-LD API document, where this doesn't seem to be really covered. It only covers the case where the map only contains a @language entry, in which case it is ignored:

If result is a map that contains only the entry @language, return null.

More complex cases are not covered. In the playground, only the d map is dropped in the following example:

{
  "http://a": {
    "@id": "http://a",
    "@language": "fr"
  },
  "http://b": {
    "@id": "http://b",
    "@language": "en",
    "@direction": "ltr"
  },
  "http://c": {
    "@id": "http://c",
    "@direction": "ltr"
  },
  "http://d": {
    "@language": "fr"
  },
  "http://e": {
    "@language": "en",
    "@direction": "ltr"
  },
  "http://f": {
    "@direction": "ltr"
  }
}

In my case, I drop d, e and f while removing the problematic entries in a, b and c. Is that a wrong interpretation of the expansion algorithm?

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

Read the JSON-LD API document's expansion algorithm and compare its handling of maps containing only @language and @direction with the examples in the issue. Check the playground behavior for entries a–f; done means the normative treatment of these cases is decided and the specification or related examples clearly reflects it.

Written by the indexing model from the issue text.

Assessment

Tech stack
json
Domain
documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.