- From: Dave Longley <dlongley@digitalbazaar.com>
- Date: Wed, 13 Apr 2016 17:10:13 -0400
- To: François-Paul Servant <francoispaulservant@gmail.com>, public-linked-json@w3.org
On 04/13/2016 04:22 PM, François-Paul Servant wrote:
> Hi,
>
> there is something that I do not understand in the output of the compaction algorithm.
>
> For the following JSON-LD:
> {
> "@context" : {
> "label": {
> "@id" : "http://www.vocab.net/label",
> "@type" : "http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"
> },
> "homepage": {
> "@id": "http://www.vocab.net/homepage",
> "@type": "@id"
> }
> },
>
> "@id" : "http://www.a.com",
> "label": {
> "@value" : "a dot com",
> "@language" : "fr"
> },
> "homepage": "http://www.a.com/home”
>
> that is, in turtle:
> <http://www.a.com>
> <http://www.vocab.net/homepage> <http://www.a.com/home>;
> <http://www.a.com> <http://www.vocab.net/label> "a dot com"@fr .
>
> }
>
> why do we get the following compacted form (output of the JSON-LD playground, using same context, that I omit below):
>
> "@id": "http://www.a.com",
> "homepage": "http://www.a.com/home",
> "http://www.vocab.net/label": {
> "@language": "fr",
> "@value": "a dot com"
> }
>
> (why "http://www.vocab.net/label", not just "label"?)
Because the `@type` doesn't match. JSON-LD doesn't know anything about
RDF types like `langString`. It just sees that the value for
"http://www.vocab.net/label" uses `@language` and not `@type` with a
matching URI.
JSON-LD does know about the keyword `@language` though. So use that in
your context instead if you want a simple `label` term in the output
that is restricted to values that use the french language:
{
"@context": {
"label": {
"@id": "http://www.vocab.net/label",
"@language": "fr"
},
"homepage": {
"@id": "http://www.vocab.net/homepage",
"@type": "@id"
}
}
}
--
Dave Longley
CTO
Digital Bazaar, Inc.
Received on Wednesday, 13 April 2016 21:10:38 UTC