schema.org - 我可以使用@id 将多个 JSON-LD 脚本连接到一个有效对象吗?
问题描述
这是有效的吗?我需要一个机会将一页上的不同脚本块加入到有效对象中。
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Product",
"@id": "#111",
"description": "Test description",
"name": "My Product"
}
</script>
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Product",
"@id": "#111",
"aggregateRating": {
"@type": "AggregateRating",
"ratingValue": "3.5",
"reviewCount": "11"
}
}
</script>
解决方案
为什么要加入这些脚本?它们描述了相同的产品,并且部分是多余的。
但是,如果您正在寻找通过 id 加入脚本的可能性 - 是的,它存在。即您有两个脚本:第一个 - 产品及其评级,第二个 - 提供该产品的组织。在这种情况下,加入看起来像:
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Organization",
"makesOffer": {
"@type": "Offer",
"itemOffered": {
"@type": "Product",
"@id": "https://www.example.com#111"
}
}
}
</script>
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Product",
"id": "https://www.example.com#111",
"aggregateRating": {
"@type": "AggregateRating",
"ratingValue": "3.5",
"reviewCount": "11"
}
}
</script>
推荐阅读
- javascript - 三.js 怎么解决这个问题?(获取 physijs_worker 404(未找到))
- android - 有没有办法让两个 Android 手表(例如三星)通过 NFC 或蓝牙相互通信?
- c# - 如何在委托函数中使用参数?
- javascript - Reactjs 提交多个表单
- linux - u-boot:尽管内核小于最大 BOOTM_LEN,但无法启动 linux 内核
- python - ATBSWP 第 2 版第 12 章,打开 google 或其他网站的所有搜索结果不起作用
- c# - 如何根据另一张表的 ID(作为外键)插入到一张表中?
- python - 对 DataFrame 进行排序以显示带有计数的项目组合
- python - Django Wagtail - 如何设置日期格式?
- gdb - 信息行 *0x000000 与 MI