19

I like to add json-ld to my website before that I want to add it to my dev site to test it

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "Organization",
  "url": "xxxxxxxxxxxxxxxx",
  "contactPoint": [{
    "@type": "ContactPoint",
    "telephone": "+xx-xxx-xxx-xxxx",
    "contactType": "customer service"

  }]
}
</script>

I get the error stating that Missing '}' or object member name. what is this error,I have closed brackets correctly.how to fix it kindly help

2
  • It may be valid JSON, but it's not valid javascript. Commented Jun 27, 2016 at 12:11
  • Where do you get this error? Commented Jun 27, 2016 at 13:56

9 Answers 9

54

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>
Sign up to request clarification or add additional context in comments.

4 Comments

Also This should be the accepted answer as per Question asked
Original question didn't have trailing commas.
Google Search Console gives this error - "Parsing error: Missing '}' or object member name" - for pages with an unnecessary comma.
2020 and this anomaly still exists. Do not forget double quotes to all "key":"values" as well. Is google bots connected to their AI department ??
9

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.

Comments

5

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.

Comments

5

I faced the same issue and found a unusual reason for the error. In my case an unknown blank character was causing the issue.

I simply replaced all those unknown blank characters with spaces and it worked for me.

Se attached images.

enter image description here

enter image description here

Comments

1

If your schema have this

&quot;

then try to replace it with normal

"

Comments

1

The Rich Result Test tool also shows this error for large JsonLD inputs.

I wonder if this is just a limitation of the test tool or google crawlers also follow this rule.

1 Comment

I can double on that. Faced the same problem. The validation passed when I removed some parts of the schema to reduce the size. Unfortunately there is no official document to confirm this.
1

I had the same issue and it was simply a case of removing trailing spaces that were after a comma.

Specifically "ratingValue": "4.9", became "ratingValue": "4.9",in this block:

"aggregateRating":
    {
        "@type": "AggregateRating",
        "ratingValue": "4.9",  
        "bestRating": "5",
        "reviewCount": "91"
    }

Comments

0

Same problem happened to me. In my case, it works just deleting the last coma after "" and putting and the end after }.

"contactType": "customer service"     <== 
(YOU DONT HAVE COMMA HERE, BUT IF THIS IS THE CASE YOU SHOULD DELETE THE COMA)

   }],     <==(AND PUT IT HERE)
},     <==(OR HERE, YOU JUST TRY IT)

Comments

0

I encounter the same problem, but this is not just all about extra commas and spacing.

just change this:

{
  "@context": "http://schema.org",
  "@type": "Organization",
  "url": "xxxxxxxxxxxxxxxx",
  "contactPoint": [{
    "@type": "ContactPoint",
    "telephone": "+xx-xxx-xxx-xxxx",
    "contactType": "customer service"

  }]
}

to this:

{
  "@context": "https://schema.org",
  "@type": "Organization",
  "url": "xxxxxxxxxxxxxxxx",
  "contactPoint": [{
    "@type": "ContactPoint",
    "telephone": "+xx-xxx-xxx-xxxx",
    "contactType": "customer service"

  }]
} 

The problem simply occurs because yours is "http://schema.org", and it must be changed to "https://schema.org"

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.