Re: using object keys in JSON-LD

On 10/06/2014 12:43 PM, Markus Lanthaler wrote:
> 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?
Thanks Markus! It does help me to understand it much better, I hope :)

While in as:UrlTemplate we may actually prefer that parameters do NOT
map to predicates, in as:Object we would probably prefer that actions do
map to predicates. So new pattern with array solves possible issue with
previous pattern with an object:
https://github.com/jasnell/w3c-socialwg-activitystreams/issues/17

I try to think if we can extract some kind of 'rule of thumb' here for
potential JSON-LD Best Practices document.

Received on Monday, 6 October 2014 11:41:43 UTC