RE: using object keys in JSON-LD

Hi Pavlik,

On 4 Okt 2014 at 13:50, ☮ elf Pavlik ☮ wrote:
> ActivityStreams defines (unless it recently changed) UrlTemplate and
> ParametersObject in https://github.com/jasnell/w3c-socialwg-
> activitystreams/blob/54deeb6d6aa742ffe4e1d6c6e09cb84cdf3123b4/activitystr
> eams2- actions.html#L1035
> 
> where we can see that as:parameters takes *an object* (not sure about an
> array of objects here...)

Let's discuss as specific example from the document you reference above:

    "review": { 
       "objectType": "UrlTemplate", 
       "template": "http://example.org/notes/{noteid}", 
       "parameters": { 
         "noteid": { 
           "type": "nonNegativeInteger", 
           "totalDigits": 5 
         } 
       } 
     }


> I can't yet clearly explain possible issues with using object keys this
> way. To my understanding in JSON-LD object keys always map to
> *predicates* which limits them to IRIs (no blank nodes or literal values
> unless serializing Generalized RDF) which can make difference here.

In JSON-LD "object keys", as you call them, don't always have to map to predicates. In the example above, "noteid" *probably* shows such a use case. It represents/describes the variable "noteid" in the URL template. Hydra makes this a bit more explicit (hydra:variable) but you can also handle the AS way of doing it with JSON-LD, but it won't result in meaningful RDF. The trick is to use a feature called "Data Indexing" [1]. Simply speaking, it allows you to add index data in a similar way as language maps do but with the difference that the index has no meaning at all. It is simply a string token that would be lost when converting to RDF. It survives all JSON-LD transformations (expansion/compaction etc.) though.

Does this answer your question?


Cheers,
Markus


[1] http://www.w3.org/TR/json-ld/#data-indexing


--
Markus Lanthaler
@markuslanthaler

Received on Monday, 6 October 2014 10:44:33 UTC