JSON-LD 1.0 @graph syntax #106

Closed
msporny opened this Issue Apr 22, 2012 · 4 comments

Projects

None yet

3 participants

@msporny
Member
msporny commented Apr 22, 2012

We need to determine what the JSON-LD 1.0 @graph syntax supports. At the moment, I think the current direction is to support the following:

  1. Support named graphs by having @id and @graph at the same level, where @id expresses the name of the graph.
  2. Both IRIs and BNode-like labels (starting with '_:') can be used in @id to name a graph.
  3. The @graph keyword is alias-able.
  4. The @graph keyword is always associated with an IRI - in JSON, represented by a string, an object with an @id, or an array of objects with @ids.
  5. A JSON-LD property MAY be associated with a {"@graph": ...} object.
  6. The JSON-LD keywords MUST NOT be associated with a {"@graph": ...} object - especially @id and @value.

We also need to figure out how @graph is treated when compacting, expanding and framing - but I believe those decisions probably will not affect the syntax. Anything else that should be considered regarding @graph syntax?

@gkellogg
Member

Need to outline a graph including graph example, and describe framing approaches.

@lanthaler
Member

RESOLVED: Adopt the 6 points in ISSUE-106 along with Gregg and Longley's proposal for @graph processing in framing as the way we approach named graph support in JSON-LD.

@gkellogg
Member

Just to clarify proposed @graph semantics:

If @graph references an IRI or subject reference, the semantics are that the statements made by the referenced document are to be considered in the named graph specified by the source document. A processor does not dereference the document to do this, it is left to the application.

Source document:

{
  "@context": {
    "wd": "http://data.wikipedia.org/vocab#",
    "ws": "http://data.wikipedia.org/snaks/",
    "wp": "http://en.wikipedia.org/wiki/"
  },
  "@id": "ws:BerlinFact",
  "@type": "wd:Snak",
  "@graph": "ws:BerlinFact",
  "wd:assertedBy": "http://www.statistik-berlin-brandenburg.de/"
}

Target document:

{
  "@context": {
    "wd": "http://data.wikipedia.org/vocab#",
    "ws": "http://data.wikipedia.org/snaks/"
  },
  "@id": "wp:Berlin",
  "wd:population": 3499879
}

The target document is defined by the source document to be in the graph named with ws:BerlinFact.

@gkellogg
Member

The issue of named graphs containing other named graphs can be illustrated by the following document:

{
  "@context": {
    "wd": "http://data.wikipedia.org/vocab#",
    "ws": "http://data.wikipedia.org/snaks/",
    "wp": "http://en.wikipedia.org/wiki/"
  },
  "@id": "ws:Assertions",
  "@type": "wd:SnakSet",
  "@graph": {
    "@id": "ws:BerlinFact",
    "@type": "wd:Snak",
    "@graph": {
      "@id": "wp:Berlin",
      "wd:population": 3499879
    },
    "wd:assertedBy": "http://www.statistik-berlin-brandenburg.de/"
  }
}

This has a default graph referencing a named graph, which in turn references another named graph. The idea would be that graph names all exist in the default graph, so this document would be semantically equivalent to the following:

{
  "@context": {
    "wd": "http://data.wikipedia.org/vocab#",
    "ws": "http://data.wikipedia.org/snaks/",
    "wp": "http://en.wikipedia.org/wiki/"
  },
  "@graph": [
    {
      "@id": "ws:Assertions",
      "@type": "wd:SnakSet",
      "@graph": {
        "@id": "ws:BerlinFact",
        "@type": "wd:Snak",
        "wd:assertedBy": "http://www.statistik-berlin-brandenburg.de/"
      }
    },
    {
      "@id": "ws:BerlinFact",
      "@type": "wd:Snak",
      "@graph": [{
        "@id": "wp:Berlin",
        "wd:population": 3499879
      }]
    }
  ]
}

That is, in the default graph, two objects ("ws:Assertions" and "ws:BerlinFact"), that each have some properties and name graphs containing other information. Note that "ws:BerlinFact" is a subject both to name a graph, and to express properties in another named graph.

This can be demonstrated by looking at the results of converting the first document to TriG:

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix wd: <http://data.wikipedia.org/vocab#> .
@prefix wp: <http://en.wikipedia.org/wiki/> .
@prefix ws: <http://data.wikipedia.org/snaks/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

{
  ws:Assertions a wd:SnakSet .
}

ws:Assertions {
  ws:BerlinFact a wd:Snak;
     wd:assertedBy "http://www.statistik-berlin-brandenburg.de/" .
}

ws:BerlinFact {
  wp:Berlin wd:population 3499879 .
}

The flattening algorithm would (eventually) be updated to take this into consideration. Note that the process of converting the first to RDF and back again would also result in the second.

@gkellogg gkellogg added a commit that referenced this issue Apr 24, 2012
@gkellogg gkellogg Update expansion and compaction behavior for @graph to ensure that it…
… is treated as if there is a default @type: @id context.

Add issues to framing and subject flattening that it needs to be considered. This closes issue #106.
99d7718
@gkellogg gkellogg closed this Apr 24, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment