digitalbazaar / jsonld.js

A JSON-LD Processor and API implementation in JavaScript
https://json-ld.org/
Other
1.66k stars 195 forks source link

`@nest` and scoped context do not work as expected #424

Open pchampin opened 3 years ago

pchampin commented 3 years ago

Example on the playground A scoped context in a @nest attribute seems to be ignored. Given this:

{
  "@context": {
    "@vocab": "http://example.org/vocab#",
    "p1": {
      "@id": "@nest",
      "@context": {
        "p2": "http://example.org/ns#P2"
      }
    }
  },
  "p1": {
    "p2": "foo"
  }
}

I would expect

[
  {
    "http://example.org/ns#P2": [
      {
        "@value": "foo"
      }
    ]
  }
]

but the playground gives me

[
  {
    "http://example.org/vocab#p2": [
      {
        "@value": "foo"
      }
    ]
  }
]

Note that removing the @vocab in the context results in the playground returning an empty array, which is consistent with the fact that it ignores the scoped context of p1, while I would expect the same result as the one I expect with the @vocab present.