Property nesting/transparent properties

Layering on PR #430 [1] is PR #451 [2]. This adds the `@nest` keyword to allow semantically meaningless nesting as requested in Issue #246 [3].

As discussed in the issue, you can have JSON-LD such as the following:

    {
      "@context": {
        "skos": "http://www.w3.org/2004/02/skos/core#",
        "labels": "@nest",
        "main_label": {"@id": "skos:prefLabel"},
        "other_label": {"@id": "skos:altLabel"},
        "homepage": {"@id":"http://schema.org/description", "@type":"@id"}
      },
      "@id":"http://example.org/myresource",
      "homepage": "http://example.org",
      "labels": {
         "main_label": "This is the main label for my resource",
         "other_label": "This is the other label"
      }
    }

This causes the “labels” property (aliased to @nest) to “pass through” to bring the “main_label” and “other_label” properties into the node definition, making it equivalent to the following:

    {
      "@context": {
        "skos": "http://www.w3.org/2004/02/skos/core#",
        "labels": "@nest",
        "main_label": {"@id": "skos:prefLabel"},
        "other_label": {"@id": "skos:altLabel"},
        "homepage": {"@id":"http://schema.org/description", "@type":"@id"}
      },
      "@id":"http://example.org/myresource",
      "homepage": "http://example.org",
      "main_label": "This is the main label for my resource",
      "other_label": "This is the other label"
    }

You can also declare a property to have @container: @nest, which will cause the property to appear under @nest (or a term aliased to @nest) when compacted:

     {
       "@context": {
         "skos": "http://www.w3.org/2004/02/skos/core#",
         "labels": "@nest",
         "main_label": {"@id": "skos:prefLabel", "@container": "@nest"},
         "other_label": {"@id": "skos:altLabel", "@container": "@nest"},
         "homepage": {"@id":"http://schema.org/description", "@type":"@id"}
       },
       "@id":"http://example.org/myresource",
       "homepage": "http://example.org",
       "labels": {
          "main_label": "This is the main label for my resource",
          "other_label": "This is the other label"
       }
     }

While this can be separated from PR #430, they can probably be taken together (and the PR is inclusive of #430).

Gregg Kellogg
gregg@greggkellogg.net

[1] https://github.com/json-ld/json-ld.org/pull/430
[2] https://github.com/json-ld/json-ld.org/pull/451
[3] https://github.com/json-ld/json-ld.org/issues/246

Received on Tuesday, 10 January 2017 03:18:24 UTC