Figuring out error in Rich Results Test

I am testing my rich snippets data on this page: https://search.google.com/test/rich-results

I repeatedly get “Structured data with syntax errors detected” and then "Parsing error: Missing ‘,’ or ‘}’ " and a line of the script is highlighted.

Question: Would the problem be more likely to be above that line, or below it? I’ve been working on addressing errors for over an hour trying to address this one issue, but I’m not sure which direction to look. Everything looks good. I’m not comfortable putting this script online (even though it’ll be made public once it works).

You’re really hampering the ability for someone to answer without posting some sort of code to look at, but I would venture that it’s most likely above it.

It’s most likely an errant number of brackets. But whether it’s too many because you’ve opened results more than you’ve closed, or too few because you’ve attempted to close more than you opened, dunno. Open the resulting code in a decent IDE, and use the highlighting feature on the brackets to ensure you’ve got a 1:1 correlation.

1 Like

The Net Beans IDE doesn’t give any errors.

<script type="application/ld+json">
{
	"@context": "https://schema.org/",
	"@type": "Dataset",
	"name": "",
	"url":["https://www..../index.html", "http://bit.ly/..."],
	"description": "",
	"keywords":["","","","",""],
	"author":{
	"@type": "Corporation",
	"name": ""
	}
	{
	"@type": "HowTo",
	"name": "",
	"url": "https://",
	"description": ""
	}
	{
	"@type": "HowTo",
	"name": "",
	"url": "https://",
	"description": ""
	}
	{
	"@type": "HowTo",
	"name": "",
	"url": "https://",
	"description": ""
	}
	{
	"@type": "HowTo",
	"name": "",
	"url": "https://",
	"description": ""
	}
	{
	"@type": "HowTo",
	"name": "",
	"url": "https://",
	"description": ""
	}
	{
	"@type": "HowTo",
	"name": "",
	"url": "https://",
	"description": ""
	}
}
</script>

You’re missing commas (just what the error message said).

Basically, there should be commas before and after each the iterations of this:

	{
	"@type": "HowTo",
	"name": "",
	"url": "https://",
	"description": ""
	}
<script type="application/ld+json">
{
	"@context": "https://schema.org/",
	"@type": "Dataset",
	"name": "",
	"url":["https://www..../index.html", "http://bit.ly/..."],
	"description": "",
	"keywords":["","","","",""],
	"author":{
	"@type": "Corporation",
	"name": ""
	},
	{
	"@type": "HowTo",
	"name": "",
	"url": "https://",
	"description": ""
	},
	{
	"@type": "HowTo",
	"name": "",
	"url": "https://",
	"description": ""
	},
	{
	"@type": "HowTo",
	"name": "",
	"url": "https://",
	"description": ""
	},
	{
	"@type": "HowTo",
	"name": "",
	"url": "https://",
	"description": ""
	},
	{
	"@type": "HowTo",
	"name": "",
	"url": "https://",
	"description": ""
	},
	{
	"@type": "HowTo",
	"name": "",
	"url": "https://",
	"description": ""
	}
}
</script>
1 Like

Actually, I’m not sure that’s 100% correct as it looks like these fields are listed above as well. Double check the format to ensure it’s correct and valid. There may be fields missing.

I’ve seen it with commas after } and without. Getting the error both ways.

Hence why I said check the format - there are slight variances in the format depending on the type of data being returned. A breadcrumb != books != movies. Which format are you trying to return?

Edit: OK, I see you’re looking at dataset. But it looks like you’re trying to return multiple datasets at once, and all the examples I see only have one element returned. So this would be the only valid return.

Edit 2: As an educational exercise, this passed the validator. Your URL was invalid, as were the values (or lack thereof) in description and name. Also added creator and license which cause warnings because they are optional. This format is all green.

<script type="application/ld+json">
{
	"@context": "https://schema.org/",
	"@type": "Dataset",
	"name": "Test me",
	"description": "A test description goes here. A test description goes here.",
	"url":["https://www.somewhere.com/index.html", "http://bit.ly/..."],
	"keywords":["","","","",""],
	"author":{
		"@type": "Corporation",
		"name": ""
	},
            "license" : "https://creativecommons.org/publicdomain/zero/1.0/",
          "creator":{
             "@type":"Organization",
             "name": "Sub dataset 01 creator"
          }
}
</script>

I’m not sure what you’re trying to pass with the additional links, but you should refer to the doc for valid values/formats: https://developers.google.com/search/docs/advanced/structured-data/dataset

1 Like

A link from that page led me to multiple “@type”: “Dataset”, on the same page: https://developers.google.com/search/docs/advanced/structured-data/dataset That generated errors, too.

Based on another page, I changed it to “HowTo.”

When I uploaded the page and did a search for the page, the page showed up with each “name”: showing, one under the other, but not the URLs or descriptions.

Right. But all the additional pages are under the HasPart element, which is an array of additional pages.

You can only pass one object to the parser. That object can have several objects underneath it, but there is only one main object.

1 Like

I used the HasPart scheme with the Datasets array and still got errors. Maybe the array was fine and the error was elsewhere. Will try that formatting again.

Bingo! Your reply made me go back and try again. This works, all green:

<script type="application/ld+json">
{
    "@context": "https://schema.org/",
    "@type": "WebSite",
    "name": "",
	"url":"https://www",
    "description": "",
	"keywords":
	[
		"",
		"",
		"",
		"",
		"
	],
    "author":{
        "@type": "Corporation",
        "name": ""
	},
  "hasPart" : [
	{
	"@type": "Dataset",
	"name": "",
	"url": "https://www",
	"description": "",
          "license" : "https://www.",
          "creator":{
             "@type":"Organization",
             "name": ""
          }
	},
	{
	"@type": "Dataset",
	"name": "",
	"url": "https://www",
	"description": "",
          "license" : "https://www.",
          "creator":{
             "@type":"Organization",
             "name": ""
          }
	},
	{
	"@type": "Dataset",
	"name": "",
	"url": "https://www",
	"description": "",
          "license" : "https://www.",
          "creator":{
             "@type":"Organization",
             "name": ""
          }
	},
	{
	"@type": "Dataset",
	"name": "",
	"url": "https://www",
	"description": "",
          "license" : "https://www.",
          "creator":{
             "@type":"Organization",
             "name": ""
          }
	},
	{
	"@type": "Dataset",
	"name": "",
	"url": "https://www",
	"description": "",
          "license" : "https://www.",
          "creator":{
             "@type":"Organization",
             "name": ""
          }
	},
	{
	"@type": "Dataset",
	"name": "",
	"url": "https://www",
	"description": "",
          "license" : "https://www.",
          "creator":{
             "@type":"Organization",
             "name": ""
          }
	}]
}
</script>

I take it this is an edited version of the green? Because that doesn’t work for me…

But I’m glad you got it working…

I tried again with all the content intact and it was fully green. I tested here, pasting the code into the Code tab in the link in my first post.

When I copied just the code without the content, I got 6 errors. Some of those errors were from fields not filled out (URL not complete, etc.). So it’s fine; just needs to be filled out fully.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.