Skip to content

Instantly share code, notes, and snippets.

@kasei
Last active December 24, 2019 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kasei/4ca7034c0f9758661c2c6a1af0f64927 to your computer and use it in GitHub Desktop.
Save kasei/4ca7034c0f9758661c2c6a1af0f64927 to your computer and use it in GitHub Desktop.
JSON-LD 1.1 issue with dropping @language-only objects

Test t0008:

{
  "@context": {
    "ex": "http://example.org/vocab#"
  },
  "@id": "http://example.org/test",
  "ex:test": { "@value": "test",  "@language": "en" },
  "ex:drop-lang-only": { "@language": "en" },
  "ex:keep-full-value": { "@value": "only value" }
}

expands to:

[
  {
    "@id": "http://example.org/test",
    "http://example.org/vocab#test": [ { "@value": "test", "@language": "en" } ],
    "http://example.org/vocab#keep-full-value": [ {"@value": "only value"} ]
  }
]

Based on the expansion algorithm steps 17 and 20, I'm not sure why ex:drop-lang-only is dropped.

Expansion 13.9 will recursively call expansion on "ex:drop-lang-only": { "@language": "en" }, and steps 17 and 20 will result in an empty array being returned.

I think 13.10 is where dropping is expect to happen, but that cannot occur because expanded value is not null, it's an empty array.

@kasei
Copy link
Author

kasei commented Dec 24, 2019

Step 17 needs to change to return null early instead of allowing step 20 to change it to an empty list.

@kasei
Copy link
Author

kasei commented Dec 24, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment