Creating an array of products in JSON-LD
Asked Answered
T

1

7

Can someone spot what's wrong with my code below? (It doesn't validate in the Google Structured Testing Tool.) I'm trying to create the JSON-LD code to add to a page that has multiple products for sale.

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@graph": [
{
  "@type": “Product”,
  "name": “tshirt",
  “description”: "test copy 1.”,
  “image”: “image.jpg”
},
{
  "@type": “Product”,
  "name": “tshirt 2",
  “description”: "test copy 2.”,
  “image”: “image2.jpg”
}
]
}
</script>

Any help is much appreciated!

Thordis answered 30/7, 2015 at 16:16 Comment(0)
C
6

You are using instead of " in some places.

Replacing these, your snippet validates:

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@graph": [
{
  "@type": "Product",
  "name": "tshirt",
  "description": "test copy 1.",
  "image": "image.jpg"
},
{
  "@type": "Product",
  "name": "tshirt 2",
  "description": "test copy 2.",
  "image": "image2.jpg"
}
]
}
</script>

Update: this snippet doesn't validate by using Google Rich Results Test anymore. Schema is being actively developed, so sometimes the requirements change after a while. For a list of products, Google is suggesting so called carousel.

Companion answered 30/7, 2015 at 17:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.