如何解决解析错误:Google 的 Rich Result Test 工具中缺少“,”或“}”
我在 Google Rich 结果工具上运行此代码,它在第 21-25 Parsing error: Missing ',' or '}'
行向我显示此错误,我试图找到缺少的逗号或括号的位置,但没有完全理解,如果有人的话知道问题出在哪里,非常感谢。我还使用了谷歌结构化数据测试工具,它也在第 21 行显示错误
代码如下:
<script data-desc="SEO-organization" type="application/ld+json">
{
"@context": "http://schema.org","@type": "Organization","@id": "https://stockphototees.com#organization","name": "Stock Photo Tees","url": "https://stockphototees.com","logo": {
"type": "ImageObject","url": "https://cdn.shopify.com/s/files/1/1501/0626/t/25/assets
/pluginSEO_structuredDatalogo_small.png?v=6356307188231393273"
},"image": "https://cdn.shopify.com/s/files/1/1501/0626/t/25/assets
/pluginSEO_structuredDatalogo_small.png?v=6356307188231393273","
sameAs": ["https://www.facebook.com/stockphototees"]
}
</script><script data-desc="SEO-product" type="application/ld+json">
{
"@context": "http://schema.org/","@type": "Product","@id": "https://stockphototees.com/products/firm-handshakebetween-business-associates#product","name": "Firm Handshake Between "Business Associates" sweatshirt","image": "https://cdn.shopify.com/s/files/1/1501/0626/products
/firm_handshake_between_business_associates_-
_adobe_stock_apparel_450x450.png?v=1600273744","description": "Put. That coffee. Down. Coffee's for closers
only. nothing says you do business more than this iconic handshake
image. Always be closing: wear this sweatshirt. Sizing information ","mpn": "7865498313","brand": {
"@type": "Thing","name": "Stock Photo Tees"
},"offers": {
"priceCurrency": "USD","lowPrice":30.99,"highPrice":30.99,"availability": "OutOfStock","offerCount":1,"seller": {
"@type": "Organization","@id": "https://stockphototees.com#organization"
}
},"model": [{
"@type": "ProductModel","@id": "https://stockphototees.com/products/firmhandshake-between-business-associates#productModel=25326698121","url": "https://stockphototees.com/products/firmhandshake-between-business-associates?variant=25326698121","name": "Firm Handshake Between Business Associates
sweatshirt XS","mpn": "25326698121","sku": "","weight": {
"@type": "QuantitativeValue","value": 292,"unitCode": "GRM"
},"additionalProperty": [{
"@type": "PropertyValue","name": "Size","value": "XS"
}],"image": "https://cdn.shopify.com/s/files/1/1501
/0626/products/mockup-f75a6cd3_450x450.jpg?v=1600273720","offers": {
"@type": "Offer","priceCurrency": "USD","@id": "https://stockphototees.com#organization"
}
}
},{
"@type": "ProductModel","@id": "https://stockphototees.com/products/firmhandshake-between-business-associates#productModel=25326698185","url": "https://stockphototees.com/products/firmhandshake-between-business-associates?variant=25326698185","name": "Firm Handshake Between Business Associates
sweatshirt S","mpn": "25326698185","value": 306,"value": "S"
}],"price":30.99,"@id": "https://stockphototees.com/products/firmhandshake-between-business-associates#productModel=25326698249","url": "https://stockphototees.com/products/firmhandshake-between-business-associates?variant=25326698249","name": "Firm Handshake Between Business Associates
sweatshirt M","mpn": "25326698249","value": 323,"value": "M"
}],"@id": "https://stockphototees.com/products/firmhandshake-between-business-associates#productModel=25326698313","url": "https://stockphototees.com/products/firmhandshake-between-business-associates?variant=25326698313","name": "Firm Handshake Between Business Associates
sweatshirt L","mpn": "25326698313","value": 366,"value": "L"
}],"@id": "https://stockphototees.com/products/firmhandshake-between-business-associates#productModel=25326698441","url": "https://stockphototees.com/products/firmhandshake-between-business-associates?variant=25326698441","name": "Firm Handshake Between Business Associates
sweatshirt XL","mpn": "25326698441","value": 377,"value": "XL"
}],"@id": "https://stockphototees.com/products/firmhandshake-between-business-associates#productModel=25326698505","url": "https://stockphototees.com/products/firmhandshake-between-business-associates?variant=25326698505","name": "Firm Handshake Between Business Associates
sweatshirt 2XL","mpn": "25326698505","value": 465,"value": "2XL"
}],"@id": "https://stockphototees.com#organization"
}
}
}]
}}
</script>
解决方法
因为这只是一个 JSON,所以将脚本标签的内容放入任何 JSON 编辑器(例如 https://jsoneditoronline.org,但任何其他编辑器也可以),它会指出问题。您遇到的一个特定问题(可能还有其他问题)是此处过早结束的字符串:
"name": "Firm Handshake Between "Business Associates" sweatshirt",
在这里,嵌入的引号应该像这样转义:
"name": "Firm Handshake Between \"Business Associates\" sweatshirt",
另一个问题是 description
属性嵌入了文字换行符。您需要删除它们或替换为 \n
。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。