sudan kanakavel
sudan kanakavel

Reputation: 275

JSON-LD Missing '}' or object member name. error

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

Upvotes: 19

Views: 34926

Answers (9)

Severe Ĉłaŕķ
Severe Ĉłaŕķ

Reputation: 1

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"

Upvotes: 0

airdrumz
airdrumz

Reputation: 449

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"
    }

Upvotes: 1

Naz_Jnr
Naz_Jnr

Reputation: 580

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.

Upvotes: 1

Giorgio Antoine O.
Giorgio Antoine O.

Reputation: 1

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)

Upvotes: 0

Kyo Huu
Kyo Huu

Reputation: 578

If your schema have this

&quot;

then try to replace it with normal

"

Upvotes: 1

Aefits
Aefits

Reputation: 3469

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

Upvotes: 5

Pranav Ambwani
Pranav Ambwani

Reputation: 51

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.

Upvotes: 5

P-S
P-S

Reputation: 4016

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>

Upvotes: 52

Markus Lanthaler
Markus Lanthaler

Reputation: 3823

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.

Upvotes: 9

Related Questions