JSON-LD Missing '}' or object member name. error
This snippet is completely fine. It is both valid JSON as well as valid JSON-LD. You can test it with the JSON-LD playground and Google's Structured Data Testing tool.
I ran into the exact same issue. The JSON-LD markup has nothing to do with trailing commas after the last element, etc. Yours is absolutely correct.
However, please note that single quotes or ''
are not accepted by Google. You must use double quotes or ""
for each and every key and value, including the elements in an array and not the array itself.
Usually this error is because of unneeded commas, make sure to remove the trailing comma from all last elements in every { } block.
Example snippet:
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Article",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "http://foo.bar", // Remove comma here
}, // Remove comma here
// Add other required fields if necessary
}
</script>