1

Could anyone advise why this schema below gets the following error:

Missing '}' or object member name.

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "Accommodation",
  "name" : "Le Hurel Cottage",
  "description" : "This cottage is one of 6 in a very large, newly converted, granite outbuilding on a traditional Jersey farmstead. It sleeps up to 6 adults, 1 child and 1 infant.",
  "address" : { "@type" : "PostalAddress",
           "addressCountry" : "Jersey",
           "addressLocality" : "Trinity",
           "postalCode" : "JE3 2GB",
             },
  "photo" : "TBC our image link",
  "numberOfRooms" : "3",
"LocationFeatureSpecification" : "Washing Machine",
"LocationFeatureSpecification" : "Wifi",
"LocationFeatureSpecification" : "Garden Patio",
"PetsAllowed" : "No",
}
</script>
3
  • 1
    Note: The original script above has been modified by someone to 1) exclude one of the two errant commas that caused it to throw errors (which does not serve users of this site, who are looking for problems and solutions), and 2) exclude the closing script tag, which is just plain incorrect. Editors and/or posters should refrain from correcting the problematic code in the question, as this can nullify responses, introduce new issues, and make the entry less useful for future users. Feb 8, 2019 at 17:10
  • @HenryVisotski: Good catch, I made a rollback.
    – unor
    Feb 11, 2019 at 17:18
  • Much appreciated, @unor! Feb 11, 2019 at 20:02

2 Answers 2

4

In JSON, the last key:value pair before the closing bracket of either an object or an array should not be followed with a comma. Thus, you should delete the commas in the following two lines:

"postalCode" : "JE3 2GB"
"PetsAllowed" : "No"

There's more. Google won't recognize LocationFeatureSpecification for @type of Accommodation; you have to use something like amenityFeature. Also, you can combine those three values into an array, as Google will call out the usage of three separate lines of the same key.

This should return no errors:

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "Accommodation",
  "name" : "Le Hurel Cottage",
  "description" : "This cottage is one of 6 in a very large, newly converted, granite outbuilding on a traditional Jersey farmstead. It sleeps up to 6 adults, 1 child and 1 infant.",
  "address" : { "@type" : "PostalAddress",
           "addressCountry" : "Jersey",
           "addressLocality" : "Trinity",
           "postalCode" : "JE3 2GB"
             },
  "photo" : "TBC our image link",
  "numberOfRooms" : "3",
  "amenityFeature" : [
    "Washing Machine",
    "Wifi",
    "Garden Patio"
  ],
"PetsAllowed" : "No"
}
</script>
4
  • Thank you! This has helped me a lot @henryVisotski
    – Becky
    Feb 11, 2019 at 13:07
  • Glad it worked for your site, @Becky! Feb 11, 2019 at 15:15
  • 1
    Another issue: it must be petsAllowed instead of PetsAllowed.
    – unor
    Feb 11, 2019 at 17:20
  • @unor Good point. While the Structured Data Testing Tool did not call this out, proper camel-casing would definitely be the way to go. Feb 11, 2019 at 20:04
2

Basic Information about JSON format: JSON Syntax Rules

JSON syntax is derived from JavaScript object notation syntax:

  • Data is in name/value pairs
  • Data is separated by commas
  • Curly braces hold objects
  • Square brackets hold arrays

Advanced (all programming languages related) information about JSON format: JSON (JavaScript Object Notation)

JSON is built on two structures:

  • A collection of name/value pairs. In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array.
  • An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence.

If you still fail to understand how JSON format works?, use following online JSON validators.

As Henry mentioned your code has one extra comma at line

<script type="application/ld+json">
    {
      "@context": "http://schema.org",
      "@type": "Accommodation",
      "name": "Le Hurel Cottage",
      "description": "This cottage is one of 6 in a very large, newly converted, granite outbuilding on a traditional Jersey farmstead. It sleeps up to 6 adults, 1 child and 1 infant.",
      "address": {
        "@type": "PostalAddress",
        "addressCountry": "Jersey",
        "addressLocality": "Trinity",
        "postalCode": "JE3 2GB" // , <------------------ Extra comma, remove it.
      },
      "photo": "TBC our image link",
      "numberOfRooms": "3",
      "LocationFeatureSpecification": "Washing Machine",
      "LocationFeatureSpecification": "Wifi",
      "LocationFeatureSpecification": "Garden Patio",
      "PetsAllowed": "No"
    }
</script>
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.