Skip to content

Framed @graph @container output not properly compacted #627

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gkellogg opened this issue Apr 1, 2018 · 0 comments
Closed

Framed @graph @container output not properly compacted #627

gkellogg opened this issue Apr 1, 2018 · 0 comments
Assignees

Comments

@gkellogg
Copy link
Member

gkellogg commented Apr 1, 2018

From digitalbazaar/jsonld.js#241.

When framing, anonymous named graphs are not considered simple graphs, and so are not properly compacted with "@container": "@graph" if the pruneBlankNodeIdentifiers option is false. For example:

Input

{
  "@context": {
    "@version": 1.1,
    "@vocab": "https://example.com#",
    "ex": "https://example.org/",
    "claim": {
      "@id": "ex:claim",
      "@container": "@graph"
    },
    "id": "@id"
  },
  "claim": {
    "id": "ex:1",
    "test": "foo"
  }
}

Frame

{
  "@context": {
    "@version": 1.1,
    "@vocab": "https://example.com#",
    "ex": "https://example.org/",
    "claim": {
      "@id": "ex:claim",
      "@container": "@graph"
    },
    "id": "@id"
  },
  "claim": {}
}

Because of flattening, this leads to the following before compaction:

Expanded/Framed output

```json
[
  {
    "@id": "_:b0",
    "http://example.org/claim": [
      {
        "@id": "_:b1",
        "@graph": [
          {
            "@id": "http://example.org/1",
            "https://example.com#test": [
              {
                "@value": "foo"
              }
            ]
          }
        ]
      }
    ]
  }
]

With the pruneBlankNodeIdentifiers option set to try, the @id elements are removed:

[
  {
    "http://example.org/claim": [
      {
        "@graph": [
          {
            "@id": "http://example.org/1",
            "https://example.com#test": [
              {
                "@value": "foo"
              }
            ]
          }
        ]
      }
    ]
  }
]

This allows compaction to render the following:

{
  "@context": {
    "@version": 1.1,
    "@vocab": "https://example.com#",
    "claim": {
      "@id": "ex:claim",
      "@container": "@graph"
    },
    "id": "@id"
  },
  "@graph": [
    {
      "claim": {
        "id": "ex:1",
        "test": "foo"
      }
    }
  ]
}

which is the expected result.

The proposed solution is to not make pruneBlankNodeIdentifiers an option, but the normal behavior when running in 1.1 mode. In retrospect, it was never intended that these unreferenced blank node identifiers remain, it was just a byproduct of the flattening algorithm.

@gkellogg gkellogg added this to the JSON-LD 1.1 milestone Apr 1, 2018
@gkellogg gkellogg self-assigned this Apr 1, 2018
gkellogg added a commit that referenced this issue Apr 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant