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)
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With