Skip to content

Instantly share code, notes, and snippets.

@kasei
Last active January 6, 2020 19:40
Show Gist options
  • Save kasei/98fdd1ead58ea487a993aea89f4d790d to your computer and use it in GitHub Desktop.
Save kasei/98fdd1ead58ea487a993aea89f4d790d to your computer and use it in GitHub Desktop.
JSON-LD 1.1 issue with handling @Index container mappings

Regarding test tpi07, I can't figure out how the @index handling should result in the expected test output. Expansion algorithm step 13.8.3.7.2 seems like relevant code:

If container mapping includes @index, index key is not @index, item does not have an entry @index and expanded index is not @none, initialize index property values to the concatenation of expanded index with any existing values of index key in item. Add the key-value pair (expanded index-index property values) to item. If item is a value object, it MUST NOT contain any extra properties; an invalid value object error has been detected and processing is aborted.

I'm not sure why it checks index key in item and not the expansion of index key. but even that isn't enough, as 13.8.3.7.2 will still set the 'http://example.com/regular' key to:

[
  "http://example.com/regular",
  {
	"@value": "foo"
  }
]

The first value needs expansion, and the key being set here needs to change to 'http://example.com/prop' so it overrides the existing values.

I can get the test to pass by rewriting 13.8.3.7.2 to do something like this:

If container mapping includes @index, index key is not @index, item does not have an entry @index and expanded index is not @none: Initialize expanded index key to the result of using the IRI Expansion algorithm, passing active context, index, and true for vocab. Initialize index property values to an array containing a map {'@value': index}. Append any existing values of expanded index key in item to index property values. Add the key-value pair (expanded index key-index property values) to item. If item is a value object, it MUST NOT contain any extra properties; an invalid value object error has been detected and processing is aborted.

But I'm not sure what affect that might have on other tests/code paths.

@kasei
Copy link
Author

kasei commented Jan 6, 2020

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