W3C home > Mailing lists > Public > public-hydra@w3.org > June 2014

Specifying both item's @id and @value for collections

From: Vagif Abilov <vagif.abilov@gmail.com>
Date: Wed, 25 Jun 2014 15:34:38 +0200
Message-ID: <CA+xi7+008aQGnNscuyMaR-i2WpRNe03J4g1Rm_8CrUoQA3RF0g@mail.gmail.com>
To: public-hydra@w3.org
Hello,

I have a list of items ("interests") as a part of a JSON-LD document:

{
    "@context": {
      "@base": "http://localhost/",
      "name": "http://localhost/name",
      "interests": "http://localhost/interests",
      "items": {
        "@id": "http://localhost/interest",
        "@container": "@list"
      }
    },
    "@id": "http://localhost/john",
    "name": "John",
    "interests": {
      "@context": {
        "@base": "http://localhost/",
        "items": {
          "@id": "http://localhost/interest",
          "@container": "@list"
        }
      },
      "@id": "http://localhost/john/interests",
      "@type": "http://localhost/array",
      "items": [ "Reading", "Writing" ]
    }
  }

My challenge is that I want to enrich "items" element with node id for each
individual interest, something like this:

{
    "@context": {
      "@base": "http://localhost/",
      "name": "http://localhost/name",
      "interests": "http://localhost/interests",
      "items": {
        "@id": "http://localhost/interest",
        "@container": "@list"
      }
    },
    "@id": "http://localhost/john",
    "name": "John",
    "interests": {
      "@context": {
        "@base": "http://localhost/",
        "items": {
          "@id": "http://localhost/interest",
          "@container": "@list"
        }
      },
      "@id": "http://localhost/john/interests",
      "@type": "http://localhost/array",
      "items": [
        {
          "@id": "http://localhost/123",
          "@value": "Reading"
        },
        {
          "@id": "http://localhost/456",
          "@value": "Writing"
        }
      ]
    }
  }

Unfortunately this approach doesn't work because @value can not be combined
with @id in a JSON-LD node. I wonder if there is a way to attach a node id
to a container element of a primitive type, e.g. I would like to keep
"items" element values as strings without wrapping them in a new structure.
I thought I could do this with @value specifier, but it doesn't work.

Thanks in advance

Vagif
Received on Wednesday, 25 June 2014 13:35:05 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 15:53:59 UTC