- From: Gregg Kellogg <gregg@greggkellogg.net>
- Date: Thu, 10 Apr 2014 10:57:34 -0700
- To: Vagif Abilov <vagif.abilov@gmail.com>
- Cc: public-hydra@w3.org
- Message-Id: <B54E1111-520B-4697-ADF6-50712FFB80A9@greggkellogg.net>
On Apr 10, 2014, at 1:59 AM, Vagif Abilov <vagif.abilov@gmail.com> wrote:
> Hello,
>
> I have an example of JSON document with a context, and I don't fully understand how its compacted JSON-LD is generated.
>
> Here it is. Note that the "versions" property has both @id and @type.
>
> {
> "@context": {
> "bridge": "https://confluence.nrk.no/display/RED/Ordbok#",
> "schema": "http://schema.org/",
> "versions": {
> "@id": "bridge:versions",
> "@type": "bridge:dictionary"
> },
> "items": {
> "@id": "bridge:versions",
> "@container": "@index"
> },
> "name": "schema:name",
> "version": "http://semver.org/spec/v2.0.0.html#semver",
> "description": "schema:description"
> },
> "@id": "http://localhost/api",
> "versions": {
> "@id": "http://localhost/api/versions",
> "@type": "bridge:dictionary",
> "items": {
> "v1": {
> "@id": "http://localhost/api/v1",
> "@type": "api",
> "name": "v1",
> "version": "1.0.0",
> "description": "Initial release"
> },
> "v2": {
> "@id": "http://localhost/api/v2",
> "@type": "api",
> "name": "v2",
> "version": "2.0.0",
> "description": "Includes pizza-ordering service"
> }
> }
> }
> }
>
> If I extract the context from the document and paster into a JSON-LD Playground Context field, then the Compacted JSON-LD version is generated like this:
>
> {
> "@context": {
> "bridge": "https://confluence.nrk.no/display/RED/Ordbok#",
> "schema": "http://schema.org/",
> "versions": {
> "@id": "bridge:versions",
> "@type": "bridge:dictionary"
> },
> "items": {
> "@id": "bridge:versions",
> "@container": "@index"
> },
> "name": "schema:name",
> "version": "http://semver.org/spec/v2.0.0.html#semver",
> "description": "schema:description"
> },
> "@id": "http://localhost/api",
> "bridge:versions": {
> "@id": "http://localhost/api/versions",
> "@type": "bridge:dictionary",
> "items": {
> "v1": {
> "@id": "http://localhost/api/v1",
> "@type": "http://json-ld.org/playground/api",
> "description": "Initial release",
> "name": "v1",
> "version": "1.0.0"
> },
> "v2": {
> "@id": "http://localhost/api/v2",
> "@type": "http://json-ld.org/playground/api",
> "description": "Includes pizza-ordering service",
> "name": "v2",
> "version": "2.0.0"
> }
> }
> }
> }
>
> Note that the "versions" property is written like "bridge:versions". Why's that? Because if I simply remove from the Context field "versions" type (remove the line "@type": "bridge:dictionary"), then the Compacted document is generated as expected, with "versions" property and without "bridge" prefix.
By declaring @type bridge:dictionary in the @context, you're saying that the value for the "versions" property is presumed to be a literal with that datatype, not an object referencing an entity of type bridge:dictionary. If you use "@type": "@id" in the @context, it will use the "versions" term.
Gregg
> I wonder what kind of logic is behind this.
>
> Thanks in advance
>
> Vagif Abilov
Received on Thursday, 10 April 2014 17:58:04 UTC