- From: Marisa DeMeglio <marisa.demeglio@gmail.com>
- Date: Fri, 8 Dec 2017 17:04:00 -0800
- To: Gregg Kellogg <gregg@greggkellogg.net>
- Cc: public-linked-json@w3.org
- Message-Id: <D8FFDF8F-B38A-4ED8-8206-D187BEE1EA31@gmail.com>
Hi Gregg, Thanks for your reply! I have a few questions inline below. > On Dec 8, 2017, at 4:02 PM, Gregg Kellogg <gregg@greggkellogg.net> wrote: > >> On Dec 8, 2017, at 2:28 PM, Marisa DeMeglio <marisa.demeglio@gmail.com <mailto: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# <http://www.w3.org/ns/earl#>", >> "doap": "http://usefulinc.com/ns/doap# <http://usefulinc.com/ns/doap#>", >> "dct": "http://purl.org/dc/terms/ <http://purl.org/dc/terms/>", >> }, >> >> "url": "http://schema.org/url <http://schema.org/url>", >> >> "css": "http://pending.schema.org/cssSelector <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. Ah right, not sure what example I followed to end up with that, but I see what you mean. Thanks for pointing that out! > > 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. Ok so two questions here: - does our custom vocabulary have to follow any kind of format? - is it possible in a JSON-LD file to use a term that’s not defined in any vocabulary? For example, in our report, some data is part of an internal interchange format, and it lives alongside the better-documented, more stable report data. Thanks again Marisa > > 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 01:05:04 UTC