How to fix unparsable structured data issues detected by Google Search Console

Written by - 0 comments

Published on - last updated on November 29th 2022 - Listed in Internet PHP Personal


In the past days I've added structured (json) data to all my blog articles. This (supposedly) helps for better search engine indexing and therefore search engine optimization.

But it didn't take long, until Google Search Console detected the first error on one article and sent an e-mail:

Logging into the Search Console confirms that one invalid structured data was found, on one page:

Obviously I validated the structured data using the schema validator before going live and no issues were found. Why would Google now complain about the data? And why only one one article (so far)?

Invalid JSON detected

The error/issue mentioned by Google is:

Parsing error: Missing ',' or '}'

If you've dealt with JSON in the past, you immediately know that this is a JSON parsing error. Some closing bracket or a comma (for multiple values in the same context) seems to be missing. Let's take a look at the JSON data of that affected blog article and let it run through jq (a command to parse JSON):

ck@mint ~ $ echo '{ "@context": "http://schema.org", "@type": "NewsArticle", "mainEntityOfPage": { "@type": "WebPage", "@id": "https://www.claudiokuenzler.com/blog/1126/how-to-monitor-handle-evicted-pods-container-rancher-kubernetes" }, "headline": "How to monitor and handle evicted pods (containers) in Rancher managed Kubernetes ", "image": [ "https://www.claudiokuenzler.com/graph/news/1126-rancher-evicted-pods.png" ], "datePublished": "2021-09-17T15:55:25+02:00", "dateModified": "2021-09-17T15:55:25+02:00", "author": { "@type": "Person", "name": "Claudio Kuenzler" }, "publisher": { "@type": "Person", "name": "Claudio Kuenzler" }, "description": "Whenever a Kubernetes node runs into resource problems, it tries to recover itself by "evicting" pods. This process is called the node-pressure eviction." }' | jq
parse error: Invalid numeric literal at line 1, column 734

Indeed, jq confirms a JSON parsing problem. Looking at column/character 734 in the output shows this part:

"description": "Whenever a Kubernetes node runs into resource problems, it tries to recover itself by "evicting" pods. This process is called the node-pressure eviction." }

See the problem? The word evicting is surrounded by double-quotes, which are understood as end of the description value in this JSON data.

Replace double quotes by single quotes

As my site is using PHP in the background, I used the str_replace() function to replace all the double quotes showing up in the description text, retrieved from a MySQL table and stored in variable $description:

$description = str_replace('"', "'", $description);

The final JSON output now shows single quotes surrounding the word "evicting" and is now parsable by jq:

ck@mintp ~ $ echo '{ "@context": "http://schema.org", "@type": "NewsArticle", "mainEntityOfPage": { "@type": "WebPage", "@id": "https://indev.claudiokuenzler.com/blog/1126/how-to-monitor-handle-evicted-pods-container-rancher-kubernetes" }, "headline": "How to monitor and handle evicted pods (containers) in Rancher managed Kubernetes ", "image": [ "https://indev.claudiokuenzler.com/graph/news/1126-rancher-evicted-pods.png" ], "datePublished": "2021-09-17T15:55:25+02:00", "dateModified": "2021-09-17T15:55:25+02:00", "author": { "@type": "Person", "name": "Claudio Kuenzler" }, "publisher": { "@type": "Person", "name": "Claudio Kuenzler" }, "description": "Whenever a Kubernetes node runs into resource problems, it tries to recover itself by 'evicting' pods. This process is called the node-pressure eviction." }' |jq
{
  "@context": "http://schema.org",
  "@type": "NewsArticle",
  "mainEntityOfPage": {
    "@type": "WebPage",
    "@id": "https://indev.claudiokuenzler.com/blog/1126/how-to-monitor-handle-evicted-pods-container-rancher-kubernetes"
  },
  "headline": "How to monitor and handle evicted pods (containers) in Rancher managed Kubernetes ",
  "image": [
    "https://indev.claudiokuenzler.com/graph/news/1126-rancher-evicted-pods.png"
  ],
  "datePublished": "2021-09-17T15:55:25+02:00",
  "dateModified": "2021-09-17T15:55:25+02:00",
  "author": {
    "@type": "Person",
    "name": "Claudio Kuenzler"
  },
  "publisher": {
    "@type": "Person",
    "name": "Claudio Kuenzler"
  },
  "description": "Whenever a Kubernetes node runs into resource problems, it tries to recover itself by evicting pods. This process is called the node-pressure eviction."
}

The fix can now be validated in Google's Search Console.

TL;DR: Verify your JSON data manually, then fix

When Google Search Console identified "unparsable structured data issues", first find out which page(s) is/are affected in the Search Console, then verify the JSON on that page(s). Either manually, for example with the jq command as seen above, or by using the Schema Validator online. If text is read from a database, you might have to adjust the resulting string variable as I had to.

After a few days: Issue is fixed

A couple of days later, Google finally sent an e-mail confirming that "unparsable structured data issues successfully fixed for site".

Google Search Console confirms that unparsable structured data issues successfully fixed



Add a comment

Show form to leave a comment

Comments (newest first)

No comments yet.

RSS feed

Blog Tags:

  AWS   Android   Ansible   Apache   Apple   Atlassian   BSD   Backup   Bash   Bluecoat   CMS   Chef   Cloud   Coding   Consul   Containers   CouchDB   DB   DNS   Database   Databases   Docker   ELK   Elasticsearch   Filebeat   FreeBSD   Galera   Git   GlusterFS   Grafana   Graphics   HAProxy   HTML   Hacks   Hardware   Icinga   Influx   Internet   Java   KVM   Kibana   Kodi   Kubernetes   LVM   LXC   Linux   Logstash   Mac   Macintosh   Mail   MariaDB   Minio   MongoDB   Monitoring   Multimedia   MySQL   NFS   Nagios   Network   Nginx   OSSEC   OTRS   Office   PGSQL   PHP   Perl   Personal   PostgreSQL   Postgres   PowerDNS   Proxmox   Proxy   Python   Rancher   Rant   Redis   Roundcube   SSL   Samba   Seafile   Security   Shell   SmartOS   Solaris   Surveillance   Systemd   TLS   Tomcat   Ubuntu   Unix   VMWare   VMware   Varnish   Virtualization   Windows   Wireless   Wordpress   Wyse   ZFS   Zoneminder