jsonld.js icon indicating copy to clipboard operation
jsonld.js copied to clipboard

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

Open pchampin opened this issue 5 years ago • 1 comments

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.

pchampin avatar Dec 11 '20 13:12 pchampin