@graph关键字是否仅适合同类型Schema?我的用法是否正确?
JSON-LD @graph 使用问题解答
关于@graph的使用限制
Jonathan的说法不属实。Schema.org规范中,@graph的核心作用就是允许在单个JSON-LD脚本中整合多种不同类型的结构化数据实体,完全支持同时包含MedicalCondition、Person、Review、VideoObject这些不同类型的内容,这也是官方推荐的多实体结构化数据组织方式。
你的Schema问题分析
你用@graph整合多类型实体的逻辑是正确的,但当前代码存在几处语法和类型错误,需要修正:
- 拼写错误:医生实体的
@type写成了"Perosn",正确应为"Person"。 - 实体类型混淆:第8个
@graph项(对应第一个视频)的@type错误标记为"Review",但字段都是VideoObject的属性(position、thumbnailUrl等),应改为"VideoObject"。 - 无效空字段:Person实体里有一个空键
"",需要补充正确的属性名(比如"specialty"表示医生专业)。 - 语法错误:多个Review的
ratingValue、worstRating、bestRating字段后只有逗号无值,VideoObject的position存在空白值,这些会导致JSON解析失败,需要填充合法值或修正语法。 - 未指定子实体类型:大量子实体的
@type为空字符串,比如associatedAnatomy应设为"AnatomicalStructure",reviewRating应设为"Rating",interactionStatistic的interactionType可设为"ViewAction",这样才能让搜索引擎正确识别实体关系。
修正后的核心结构示例
<script type="application/ld+json"> { "@context": "https://schema.org", "@graph": [ { "@type": "MedicalCondition", "associatedAnatomy": { "@type": "AnatomicalStructure", "name": "" }, // 其他MedicalCondition字段... }, { "@type": "Person", "name": "", "affiliation": "", "specialty": [ { "@type": "MedicalSpecialty", "name": "" } ], // 其他Person字段... }, { "@type": "Review", "author": { "@type": "Person", "name": "" }, "reviewRating": { "@type": "Rating", "ratingValue": "4", "worstRating": "1", "bestRating": "5" }, // 其他Review字段... }, { "@type": "VideoObject", "position": 1, "interactionStatistic": { "@type": "InteractionCounter", "interactionType": { "@type": "ViewAction" }, "userInteractionCount": "1000" }, // 其他VideoObject字段... } ] } </script>
内容的提问来源于stack exchange,提问作者ssc1234
相关产品推荐
相关产品推荐

