Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In JSON-LD, is it possible to define a URI mapping for a property value?

Tags:

json-ld

Suppose we have the following JSON:

{
  "@context":
  {
    "name": "http://schema.org/name",
    "status": "http://schema.org/status"
  },
  "name": "Manu Sporny",
  "status": "trollin'"
}

(JSON-LD Playground)

The trollin' status is identified with a URI: http://example.com/trolling. Is it possible to expand the trollin' keyword in the example above to the URI http://example.com/trolling?

A straightforward manipulation of the context does not work:

{
  "@context":
  {
    "name": "http://schema.org/name",
    "status": "http://schema.org/status",
    "trollin'": "http://example.com/trolling"
  },
  "name": "Manu Sporny",
  "status": "trollin'"
}

(JSON Playground)

Forcing the type of status to @id also won't work, because it will assume trollin' is a relative URI.

{
  "@context":
  {
    "name": "http://schema.org/name",
    "status": {
      "@id": "http://schema.org/status",
      "@type": "@id"
    },
    "trollin'": "http://example.com/trolling"
  },
  "name": "Manu Sporny",
  "status": "trollin'"
}

(JSON-LD Playground)

like image 879
Maarten Avatar asked Oct 29 '14 15:10

Maarten


1 Answers

Yes, you can do it, you need to set the type of status to @vocab:

{
  "@context":
  {
    "name": "http://schema.org/name",
    "status": {
      "@id": "http://schema.org/status",
      "@type": "@vocab"
    },
    "trollin'": "http://example.com/trolling"
  },
  "name": "Manu Sporny",
  "status": "trollin'"
}

Here's a link to the playground.

like image 200
Gregg Kellogg Avatar answered Oct 26 '22 02:10

Gregg Kellogg