W3C home > Mailing lists > Public > public-linked-json@w3.org > January 2017

Re: Property nesting/transparent properties

From: Niklas Lindström <lindstream@gmail.com>
Date: Tue, 10 Jan 2017 09:59:18 +0100
Message-ID: <CADjV5jdCrW0KwJ-4GQQK52DAXOcSc4hDXaCFkqRuj4gGa5hcDA@mail.gmail.com>
To: Gregg Kellogg <gregg@greggkellogg.net>
Cc: Linked JSON <public-linked-json@w3.org>
Thanks Gregg!

I commented on some design details in the issue:
https://github.com/json-ld/json-ld.org/issues/246#issuecomment-271519738

Cheers,
Niklas


On Tue, Jan 10, 2017 at 4:17 AM, Gregg Kellogg <gregg@greggkellogg.net>
wrote:

> 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 09:00:21 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 10 January 2017 09:00:22 UTC