1

As far as I can see in the JSON-LD spec, section 3.1 - The Context, @context can either be:

  • an inline JSON object:

    {
      "@context": {
        "name": "http://schema.org/name"
      }
    }
    
  • or a string representing the URI of an external JSON-LD file containing such a JSON object:

    {
      "@context": "https://json-ld.org/contexts/person.jsonld"
    }
    

However, when used with the schema.org vocabulary, @context is always used this way:

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

Even though http://schema.org is not the URI of a JSON-LD document.

What did I miss?

1

Schema.org uses content negotiation to provide the JSON-LD context file.

If you request http://schema.org while sending the request header that you accept/prefer application/ld+json, this is what happens:

  1. http://schema.org 301-redirects to https://schema.org/

    HTTP/1.1 301 Moved Permanently
    Content-Type: text/html
    Location: https://schema.org/
    
  2. https://schema.org/ 302-redirects to https://schema.org/docs/jsonldcontext.jsonld

    HTTP/1.1 302 Found
    Content-Type: text/html; charset=utf-8
    Location: https://schema.org/docs/jsonldcontext.jsonld
    
  3. https://schema.org/docs/jsonldcontext.jsonld gets delivered

    HTTP/1.1 200 OK
    Content-Type: application/ld+json; charset=utf-8
    

You can test it yourself with curl:

curl -L -H "Accept: application/ld+json" http://schema.org

-L makes curl follow redirects
-H includes the following header (Accept: application/ld+json) in the request

  • It did not even cross my mind that content negotiation could be used in this context. This makes perfect sense. Thank you! – Benjamin Jun 11 at 23:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.