json-ld-api icon indicating copy to clipboard operation
json-ld-api copied to clipboard

Compaction of IRIs with "@list" @container for sets of @list

Open progval opened this issue 3 years ago • 4 comments

Compacting this document:

{
  "http://schema.org/prop": [
    {
      "@list": ["foo", "bar"]
    },
    {
      "@list": ["baz", "qux"]
    }
  ]
}

with this context:

{
  "prop": {
    "@id": "http://schema.org/prop",
    "@container": "@list"
  }
}

produces this new document:

{
  "@context": {
    "prop": {
      "@id": "http://schema.org/prop",
      "@container": "@list"
    }
  },
  "prop": [
    "baz",
    "qux"
  ]
}

which is missing the first of the two lists.

(Tested with the JSON-LD playground , PyLD, and the ruby-ld gem)

As far as I can tell, this is caused by step 12.8.7.3 of the compaction algorithm, which sets 'item active property' first to ["foo", "bar"] then to ["baz", "qux"] causing the first value to be overwritten, and lost from the compacted document.

Is this an expected consequence of the algorithm specification?

progval avatar Aug 20 '22 05:08 progval

That is definitely not an expected result, and will require more investigation and addition tests. Thanks for reporting.

gkellogg avatar Aug 20 '22 15:08 gkellogg

Hi, I'm in the process of writing a new JSON-LD implementation. Is this something that I should take into account when writing the compliance test suite?

tchoutri avatar Nov 09 '22 16:11 tchoutri

@tchoutri great that you're working on an implementation! At some point, we should add you to the list on json-ld.org. Regarding this issue, it is considered an Erratum, which when resolved, becomes an official part of the spec, so it would make sense to consider it. Note that There are other raised Errata which still need consideration, as well as some Errata that haven't been incorporated into the spec and await a future publication, but should be considered by implementors in any case.

gkellogg avatar Nov 09 '22 17:11 gkellogg

Thanks a lot @gkellogg for your reactivity. :)

tchoutri avatar Nov 09 '22 17:11 tchoutri