Costa Michailidis
Costa Michailidis

Reputation: 8178

Why do types need to be specified in JSON-LD after the context?

In JSON-LD the @type shows up not just at the top level, but in the contactPoint property. Why is it needed if the context is already provided?

<script type="application/ld+json">
  { "@context" : "http://schema.org",
    "@type" : "Organization",
    "url" : "http://www.your-company-site.com",
    "contactPoint" : [
      { "@type" : "ContactPoint",
        "telephone" : "+1-401-555-1212",
        "contactType" : "customer service"
      }
    ]
  }
</script>

Doesn't the parser know from the context and the first @type line that we're working with an organization, and so the property contactPoint is meant to have that type of object in it? Otherwise, can I rename that property to just contact and then specifying the @type should inform what it is? The example seems redundant to me. Maybe I'm misunderstanding something about how JSON-LD is working here.

Upvotes: 2

Views: 481

Answers (1)

unor
unor

Reputation: 96607

Schema.org does not require which values a property can have. It lists the expected values, but authors don’t have to follow that, it’s just a recommendation.

For example, the expected value of the contactPoint property is an entity with the ContactPoint type. But it’s possible to use a string or a URL value instead (strictly speaking even a Thing item, or any other type).

Even if you would always follow the recommendation and use the expected type, it’s still not necessarily clear which type you mean, because

  • there are properties that expect one of several types as value (e.g., itemOffered expects Product or Service)
  • a property could expect an addtional type in a future version of Schema.org, and then it would no longer be clear which one you mean
  • an expected type of a property could be removed in a future version of Schema.org, but your already published structured data might not make sense with the new expected type

Upvotes: 3

Related Questions