Skip to content

Datasets in JSON-LD are horriblely ugly and not navigable #272

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
gcarothers opened this issue Jun 29, 2013 · 6 comments
Closed

Datasets in JSON-LD are horriblely ugly and not navigable #272

gcarothers opened this issue Jun 29, 2013 · 6 comments

Comments

@gcarothers
Copy link

"@graph": [
{
  "@id": "http://example.org/graphs/1",
  "@graph": {
    "@id": "http://example.org/people/gavin",
    "http://example.com/vocab#name": "Gavin"
  }
},
{
  "@id": "http://example.org/graphs/2",
  "@graph": {
    "@id": "http://example.org/people/manu",
    "http://example.com/vocab#name": "Manu"
  }
},
{
  "@id": "http://example.org/graphs/3",
  "@graph": {
    "@id": "http://example.org/people/Lehn",
    "http://example.com/vocab#name": "Lehn"
  }
}]

}

The outer @graph is syntax cruft and has no meaning.

@gcarothers
Copy link
Author

Example from real data: https://gist.github.com/gcarothers/5889134 a replacement design might look like: https://gist.github.com/gcarothers/5889145 creating a @dataset which then uses normal JSON-LD keys to specify each graph.

@gkellogg
Copy link
Member

This could be useful in a separate spec, but it might not take a different keyword to do it. Something we didn't get to in 1.0 is the ability to have node definitions which are indexed from an object, rather than being in an array form; there are likely elements that could be added to a context which would indicate that the values of the object containing the context are to be treated as IDs, with their values the node definition (with an optional @id, which MUST resolve to the same IRI). This would pretty much eat the RDF/JSON use case. Doing this for graph names would be pretty similar.

This would be a nice JSON-LD 1.1 feature.

@lanthaler
Copy link
Member

If you don't mind a couple of extra triples you could do something like this:

{
  "@context": {
    "dataset": { "@id": "_:dataset", "@container": "@index" }
  },
  "dataset": {
    "http://example.org/graphs/1":
      {
        "@id": "http://example.org/graphs/1",
        "@graph": {
          "@id": "http://example.org/people/gavin",
          "http://example.com/vocab#name": "Gavin"
        }
      },
    "http://example.org/graphs/2":
      {
        "@id": "http://example.org/graphs/2",
        "@graph": {
          "@id": "http://example.org/people/manu",
          "http://example.com/vocab#name": "Manu"
        }
      },
    "http://example.org/graphs/3":
      {
        "@id": "http://example.org/graphs/3",
        "@graph": {
          "@id": "http://example.org/people/Lehn",
          "http://example.com/vocab#name": "Lehn"
        }
      }
  }
}

The outer @graph is syntax cruft and has no meaning.

You don't need to use it if you don't need to specify a context at the same time:

[
  {
    "@id": "http://example.org/graphs/1",
    "@graph": {
      "@id": "http://example.org/people/gavin",
      "http://example.com/vocab#name": "Gavin"
    }
  },
  ...
]

is valid as well.

@gkellogg
Copy link
Member

This is likely solved using the @container: @graph proposal from #195; this would certainly make datasets more navigable.

@gkellogg
Copy link
Member

gkellogg commented Apr 8, 2017

I propose closing this with no change; please 👍 or 👎 to close.

@gkellogg
Copy link
Member

gkellogg commented May 4, 2017

Seems like #481 and #195 address this concern.

@gkellogg gkellogg closed this as completed May 4, 2017
@gkellogg gkellogg removed this from the JSON-LD 1.1 milestone May 4, 2017
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

3 participants