求助:从Google Search Central复制的Article结构化数据JSONLINT解析报错
结构化数据JSONLINT解析错误问题解决
你遇到的报错核心原因是:JSONLINT仅验证纯JSON格式内容,但你粘贴的代码包含了HTML的<script>标签,还混有HTML转义字符,具体问题点如下:
- 代码开头的
< script type = "application/ld+json" >和结尾的< /script>是HTML标签,JSONLINT无法识别这类非JSON语法,这是触发报错的直接原因 - 代码里的
"是HTML环境下的双引号转义实体,纯JSON里应该直接用普通双引号" - 标签里的多余空格(比如
< script里的空格、属性值前后的空格)虽然不影响浏览器解析,但会干扰纯JSON验证工具的识别
修正后的纯JSON内容(可直接在JSONLINT验证)
{ "@context": "https://schema.org", "@type": "NewsArticle", "headline": "Title of a News Article", "image": [ "https://example.com/photos/1x1/photo.jpg", "https://example.com/photos/4x3/photo.jpg", "https://example.com/photos/16x9/photo.jpg" ], "datePublished": "2015-02-05T08:00:00+08:00", "dateModified": "2015-02-05T09:20:00+08:00", "author": [{ "@type": "Person", "name": "Jane Doe", "url": "https://example.com/profile/janedoe123" }, { "@type": "Person", "name": "John Doe", "url": "https://example.com/profile/johndoe123" }] }
如果要在Webflow里使用,只需要把修正后的JSON内容放到规范的<script>标签中间即可(注意标签不要有多余空格):
<script type="application/ld+json"> { "@context": "https://schema.org", "@type": "NewsArticle", "headline": "Title of a News Article", "image": [ "https://example.com/photos/1x1/photo.jpg", "https://example.com/photos/4x3/photo.jpg", "https://example.com/photos/16x9/photo.jpg" ], "datePublished": "2015-02-05T08:00:00+08:00", "dateModified": "2015-02-05T09:20:00+08:00", "author": [{ "@type": "Person", "name": "Jane Doe", "url": "https://example.com/profile/janedoe123" }, { "@type": "Person", "name": "John Doe", "url": "https://example.com/profile/johndoe123" }] } </script>
内容的提问来源于stack exchange,提问作者Andre Timms
相关产品推荐
相关产品推荐

