Re: How to define context for new (custom) properties of JSON document

Thanks Nicholas! This helps and it confirms my understanding of json-ld
that I have to have external-vocabulary defined for every property that is
not yet modeled by well-known standard (schema.org/foaf.etc.).

Since the API I'm currently working on is going to be consumed internally
(not public), I have decided to keep it simple and use instead 'HAL
specification <http://tools.ietf.org/html/draft-kelly-json-hal>'. I
understand that per HAL it requires out-of-band mechanism to communicate
context and for that I will rely on our API documentation for now.

Thanks,
Zee.


On Sat, Oct 25, 2014 at 8:22 AM, Nicholas Bollweg <nick.bollweg@gmail.com>
wrote:

> Looks like some interesting stuff. Unfortunately, I'm not sure if
> ontologies can be all three of simple, specific, and standards-compliant,
> at the same time.
>
> I created json-ld playground link..
>>
> I didn't know that gists worked as remote docs! That's great!
>
>  how to define context for properties (keys) that doesn't have a standard
>> ontology
>>
> Congratulations, you probably have to make a new ontology!
>
> If you want simple and specific, the easiest way to blanket capture
> otherwise-unmodeled things is with @vocab, take a look at the spec
> <http://www.w3.org/TR/json-ld/#default-vocabulary>.
>
> Adding this to your context:
>
>> "@vocab": "http://myapp.com/",
>>>
>> and removing all your null pairs, as you can read there, will expand:
>
>> "twitterUserId": "x"
>>>
>> as
>
>> "http://myapp.com/twitterUserId": {"@value": "x"}
>>>
>>
> The issue now is that you have created a new vocabulary, that doesn't map
> to any other vocabularies. So how about specific and standards-compliant?
>
>
>> I lose that the image is gravatarImage not just any image
>>
> Ah, but that is what you said in your context! The above vocab thing will
> make it into a myapp:gravatarimage. If you really need it to be
> myapp:gravatarImage and sdo:image, you need to provide an additional
> mapping from myapp:gravatarImage to sdo:image...
>
>> "@context": {
>> ...
>>   "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
>>   "gravatarImage": {"@id": "http://myapp.com/gravatarImage",
>> "rdf:subPropertyOf": "sdo:image"}
>> ...
>> }
>>
>
> The user of your data would then need to support the RDF class inheritance
> stuff, which, while powerful, is not really a thing one should have to
> expect to use JSON-LD.
>
> Another way, which is simpler, but not as pretty, would just be to include
> it twice:
>
>> "gravatarImage": <url>,
>> "imgage": <url>
>>
>
> Not sure if this helps, but maybe some look into!
>

Received on Sunday, 26 October 2014 01:07:35 UTC