Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Incorrect value type "@context" in Google Rich Results Test

Im pretty new to JSON-LD and am currently struggling making the Google Rich Results Test happy with my custom JSON-LD data.

Every time I use a @context other than https://schema.org/ it shows me the error Incorrect value type "@context".

This even happens with this simple example based on a json-ld.org context:

<script type="application/ld+json">
{
  "@context": "https://json-ld.org/contexts/person.jsonld",
  "@type": "Person",
  "name": "Foo"
}
</script>

Rich Results Test Error

After some trail and error I found out that with the following code the json-ld.org/playground shows me the same result if I use @vocab

<script type="application/ld+json">
{
  "@context": {"@vocab": "http://xmlns.com/foaf/0.1/"},
  "@type": "Person",
  "name": "Foo"
}
</script>

And although Google is happy with this code I’m very uncertain if this can or should be the right solution to fix this kind of “Structured data parsing error”?

What is the correct way (that is accepted by Google) to write non-schema.org JSON-LD data?

like image 624
ausi Avatar asked Jul 08 '21 21:07

ausi


People also ask

What is Google rich result test?

Rich results are experiences on Google surfaces, such as Search, that go beyond the standard blue link. Rich results can include carousels, images, or other non-textual elements. What is this test? Test your publicly accessible page to see which rich results can be generated by the structured data it contains.


1 Answers

According to Dan Brickley (Google employee with responsibility for Schema.org) these issues will be addressed or documented for the new validator:

Thanks - noted and acknowledged. The tool is not opensource (it is a view provided by Google's structured data validation infrastructure). I will make sure these issues are addressed or documented before we link the new validator more prominently from Schema.org.

https://github.com/schemaorg/schemaorg/issues/2921#issuecomment-879817283

like image 93
fritzmg Avatar answered Oct 07 '22 11:10

fritzmg