If you use e.g. lanthaler/JsonLD to compact JSON-LD data with schema.org
context, you will notice that @type
keyword is replaced with an alias type
in the output, which makes sense given that
Schema.org recently added a keyword alias from @type to just type
The problem is that Google's Structured Data Testing Tool fails to recognize this alias. Here's a simple example to demonstrate this (try replacing type
with @type
, and it will pass validation)
{
"@context": "http://schema.org",
"type": "Product",
"name": "SomeName"
}
Which raises a few questions:
lanthaler/JsonLD
to avoid replacing @type
with type
during compaction (ideally without any other side-effects)?To answer your second question: yes, by using a different context. For instance the following:
{
"@context": {
"@vocab": "http://schema.org/"
}
}
This context ends up in the result but that is fine as the SDTT is able to process this.