JSON-LD and context questions

Hi,

Hi - following up discussions at the BioHackathon we’re looking at updating our sample serialisation. We are running into some questions with respect to the context usage and are hoping someone can help.

Specifically, I’m trying to understand the usage of contexts and base IRIS - I’m familiar with XML base and namespaces as well as RDF, but I was looking at some schema.org <http://schema.org/> JSON-LD and trying to understand nuances based on the official spec at https://www.w3.org/TR/json-ld/#the-context <https://www.w3.org/TR/json-ld/#the-context>

Here is the relevant excerpt from our serialisation:

{
  "@context": "http://schema.org <http://schema.org/>",
  "@type": "DataRecord",
  "identifier": "biosample:SAMEA100000",
  "mainEntity": {
    "@context": [
      "http://schema.org <http://schema.org/>",
      {
        "@base": "http://schema.org <http://schema.org/>"
      },
      {
        "Sample": {
          "@id": "http://purl.obolibrary.org/obo/OBI_0000747 <http://purl.obolibrary.org/obo/OBI_0000747>"
        }
      }
    ],
….


As you can see there is a repetition of contexts and base that I don’t think is needed.

1. The first context, which is at the top level in our sample page, seems to match example 4 from the spec, and would actually be a reference to another json-ld context? Though it doesn’t point to a json-ld file. I couldn’t find this specific notation anywhere else in the JSON-LD spec, but this is what is used throughout on schema.org <http://schema.org/>, eg https://schema.org/Person <https://schema.org/Person>, example 1 in json-ld.

2. The whole page is a DataRecord (where DataRecord is a new type we are proposing to schema.org <http://schema.org/>, so should expand to http://schema.org/DataRecord <http://schema.org/DataRecord>) - which is expected as we want to describe a data record in our resource, and we then describe the mainEntity in that DataRecord.
As you can see, the context is redefined in mainEntity - my understanding is that this means this specific context declaration will be valid only within the scope of that mainEntity. This context reads

    "@context": [
      "http://schema.org <http://schema.org/>",
      {
        "@base": "http://schema.org <http://schema.org/>"
      },

I don’t understand what the first "http://schema.org <http://schema.org/>” means, and whether it’s needed as we explicitly define the base. Also this seems redundant with the global page context we have defined at the page level, so I’d be tempted to just have

    "@context": {
        "@base": "http://schema.org <http://schema.org/>"
      },

At the top level.

3. Finally, we are trying to say that http://schema.org/Sample <http://schema.org/Sample> (which is a new type we’re proposing) also has the IRI "http://purl.obolibrary.org/obo/OBI_0000747 <http://purl.obolibrary.org/obo/OBI_0000747>”. I’m not sure adding

      {
        "Sample": {
          "@id": "http://purl.obolibrary.org/obo/OBI_0000747 <http://purl.obolibrary.org/obo/OBI_0000747>"
        }

In the context is the right way of doing it, or whether we should just add an additionalType <https://schema.org/additionalType> property on the sample object later on - or should we do both?

Apologies for the rather long email, but I hope we have a JSON-LD specialist on this list that can provide some guidance as to how we should best use those. Thanks in advance for any help!

Cheers,
Melanie




-- 
Mélanie Courtot, PhD
GA4GH/BioSamples Project lead
European Bioinformatics Institute (EMBL-EBI)

Received on Wednesday, 21 November 2018 13:40:47 UTC