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

I have the same issue:

 {
   "@context": {
    "lang": "@language",
    "value": "@value",
    "dublinCore": {
      "@id": "http://foo.bar/dc",
      "@context": {
         "title": "http://purl.org/dc/terms/title"
      }
    },
    "title": "http://foo.bar/title"
   },
    "@id": "http://foo.bar/obj/test",
    "title": "test",
    "dublinCore": {
      "title": [{
        "lang": "en",
        "value": "Chapter 1: Jonathan Harker's Journal"
      }]
    }
 }

Gives N-Quads:

<http://foo.bar/obj/test> <http://foo.bar/title> "Chapter 1: Jonathan Harker's Journal"@en .
<http://foo.bar/obj/test> <http://foo.bar/title> "test" .

Yet if I give a specific idea to my dublinCore, I get the expected output:

<http://foo.bar/obj/test> <http://foo.bar/dc> _:b0 .
<http://foo.bar/obj/test> <http://foo.bar/title> "test" .
_:b0 <http://purl.org/dc/terms/title> "Chapter 1: Jonathan Harker's Journal"@en .

PonteIneptique avatar Oct 29 '25 16:10 PonteIneptique