science-on-schema.org: context must be a map

So I have been running into this with @smrgeoinfo and I saw it in the example by @datadavev

Using Dave’s example of

{
  "@context":"https://schema.org/",
  "@type":"Dataset",
  "name":"test",
  "description": "This is a description of the test. Here's some more words to make it long enough."
}

If you place this in the JSON-LD playground link you will see it expands to http, not https

modify the context to a map as

{
  "@context": {
    "@vocab": "https://schema.org/"
  },
  "@type": "Dataset",
  "name": "test",
  "description": "This is a description of the test. Here's some more words to make it long enough."
}

It will expand correctly with https as at https://tinyurl.com/y99kj7d7

reference https://www.w3.org/TR/json-ld/#context-definitions

specifically:

A context definition MUST be a map whose keys MUST be either terms, 
compact IRIs, IRIs, or one of the keywords @base, 
@import, @language, @propagate, @protected, @type, @version, or @vocab.

It would appear that we need to make sure examples and recommendations (at least if we want JSON-LD 1.1, which I suspect this is part of) must be maps.

I’ve been running into this issue in some of my development work… Comments and observations welcome…

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 41 (4 by maintainers)

Commits related to this issue

Most upvoted comments

Science-on-schema.org is about recommendations for application of schema.org to this domain, and so my impression is this group should not be overriding the specification. Hence, the recommendation here should be to use the namespace as published, which would be http://schema.org/. Options for specifying the context then include:

  1. {
      "@context":"https://schema.org/"
    }
    
  2. {
      "@context":"https://schema.org/docs/jsonldcontext.jsonld"
    }
    
  3. {
      [
        "@context":"https://schema.org/",
        {
          "prov": "http://www.w3.org/ns/prov#",
          "provone": "http://purl.dataone.org/provone/2015/01/15/ontology#",
          "spdx": "http://spdx.org/rdf/terms#"
        }
      ]
    }
    
  4. {
      "@context": {
          "@vocab": "http://schema.org/"
      }
    }
    

Where:

  1. Remote context reference (note that http or https may be specified here)
  2. Functionally equivalent to (1). The JSON-LD processor should resolve to this document from (1) if it implements the specification for following link headers.^1
  3. Remote context reference for schema.org and including other namespaces. Note that other remote contexts may also be specified in the list.
  4. Ignores the remote schema.org context, but makes http://schema.org/ the default namespace for the document.

Implementors should be aware that this may change in the future (i.e. “http” -> “https”) and that existing implementations may internally use “https://schema.org/” as the namespace (e.g. RDFLib). Hence consumers should probably be applying namespace normalization to schema.org content to ensure consistent interpretation in an RDF processing environment.

Note that this issue will vaporize when schema.org v 12 comes out in March.

See: https://github.com/schemaorg/schemaorg/blob/main/data/releases/12.0/schemaorgcontext.jsonld

@datadavev

Your post above really needs to go into the docs and It’s more clear the JSON-LD docs IMHO. I do follow what you are saying and based on that I think I have a bug report to make up for a JSON-LD lib I use. 😃

We probably should update all of our examples to use the recommended form.

@bonnland

The first is valid for JSON-LD 1.0
The second for JSON-LD 1.1

If you are working at this point forward, you should be using the map, the second one.