Creating an array of products in JSON-LD

不想你离开。 提交于 2019-12-11 02:07:52

问题


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!


回答1:


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>


来源:https://stackoverflow.com/questions/31729025/creating-an-array-of-products-in-json-ld

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!