Re: usage question for custom vocabulary terms

> On Dec 8, 2017, at 2:28 PM, Marisa DeMeglio <marisa.demeglio@gmail.com> wrote:
> 
> Hello,
> 
> I hope this is the right list for this question! I’m a developer working on a tool that outputs JSON-LD and I have a question about using custom vocabulary terms. Our output currently contains a mix of preexisting vocabularies (e.g. earl, dublin core, doap) and custom terms, some of which reference external schema, and some of which are entirely ours. One such custom term is “hasManifestCallbacks”, which is super specific to our project. How do I use a custom term in a JSON-LD file? I’m not sure how to declare it in the context:
> 
> 
> {
>  "@context":
>  {
>    "earl": "http://www.w3.org/ns/earl#",
>    "doap": "http://usefulinc.com/ns/doap#",
>    "dct": "http://purl.org/dc/terms/",
>  },
> 
>  "url": "http://schema.org/url",
> 
>  "css": "http://pending.schema.org/cssSelector",
> 
>  “hasManifestCallbacks”: ??
> 
> }
> 
> Could someone point me to some examples of this? I haven’t come across any thus far.

Hi Marisa, fine place to ask such a question; many questions are asked on Stack Overflow as well.

JSON-LD has the concept of terms, which are typically defined per-vocabulary term in the context, but you can also use terms are vocabulary prefixes, as you have done above. The basic purpose of defining terms in the context is to associate them with an IRI, but you can also define things like expected type range, and container properties. This all described in some detail in the spec [1]. In particular, 5.1 The Context, 6.5 Type Coercion, and 6.7 Advanced Context Usage. You can also find examples, and play with your own on the playground [2].

Your case above defines a context containing prefixes, but then seems to define terms outside of the context; the last three terms should be included along with the prefix definition.

As for hasManifestCallbacks, you just need to associate an IRI with it to be able to use it in the document; it’s not uncommon for organizations to create their own vocabularies for this purpose, but the vocabulary should have a published IRI, and the terms should be relative to that (either using a fragment notation such as http://example.org/vocab#hasManifestCallbacks <http://example.org/vocab#hasManifestCallbacks>, or as s sub-resource such as http://example.org/vocab/hasManifestCallbacks <http://example.org/vocab/hasManifestCallbacks>. You can then use these IRIs when defining the term in your JSON-LD document.

Hope that helps.

Gregg

[1] https://www.w3.org/TR/2014/REC-json-ld-20140116/ <https://www.w3.org/TR/2014/REC-json-ld-20140116/>
[2] https://json-ld.org/playground/ <https://json-ld.org/playground/>

> Thanks
> 
> Marisa
> 
> 
> 
> 
> 
> 

Received on Saturday, 9 December 2017 00:03:24 UTC