尝试整理如何在JSON中使用isConsumableFor属性schema.org。我把主要产品设置为“覆盆子Pi 4”和isConsumableFor产品“电源”。
JSON片段是为"Raspberry Pi 4“构建的:
{
"@context":"http://schema.org/",
"@type":"Product",
"name":"Raspberry Pi 4",
"image":[
"raspberry-pi-4-model-b.jpg",
"raspberry-pi-4-model-b-2.jpg",
],
"description":"Raspberry Pi 4 ...",
"offers":{
"@type":"AggregateOffer",
"offerCount":1,
"highPrice":"40.00 ",
"lowPrice":"40.00 ",
"priceCurrency":"EUR",
"offers":[
{
"@type":"Offer",
"priceCurrency":"EUR",
"priceValidUntil":"2019-11-09T21:50:32+01:00",
"url":"Raspberry-Pi-4-Model-B",
"price":"40.00 ",
"itemCondition":"http://schema.org/New",
"availability":"http://schema.org/InStock",
}
]
}
}在Raspberry Pi 4的页面上,我要在哪里启动属性"isConsumableFor"??去树莓Pi 4还是电源?
{
"@context": "http://schema.org/",
"@type": "Product",
"isConsumableFor":{
"@context":"http://schema.org/",
"@type":"Product",
"name":"Raspberry Pi 4",
"url":"example.com",
},
}或者这样做,但如果有更多的消费品可供Raspberry Pi 4比它将重复所有时间的覆盆子Pi 4,其中一次应该是足够的所有配件:
{
"@context":"http://schema.org/",
"@type":"Product",
"name":"Power Supply",
"image":[
"psu.jpg",
"psu-2.jpg",
],
"description":"Power Supply ...",
"offers":{
"@type":"AggregateOffer",
"offerCount":1,
"highPrice":"8.00 ",
"lowPrice":"8.00 ",
"priceCurrency":"EUR",
"offers":[
{
"@type":"Offer",
"priceCurrency":"EUR",
"priceValidUntil":"2019-11-09T21:50:32+01:00",
"url":"powersupply",
"price":"8.00 ",
"itemCondition":"http://schema.org/New",
"availability":"http://schema.org/InStock",
}
]
},
"isConsumableFor":{
"@context":"http://schema.org/",
"@type":"Product",
"name":"Raspberry Pi 4",
}
}发布于 2019-11-17 06:23:18
将您的JSON修改到下面将使其对结构化数据测试工具有效,但是这种方法有几个注意事项,这取决于您如何生成内容。
我认为最好的方法是利用全局标识符(id):
覆盆子Pi
{
"@context":"http://schema.org/",
"@type":"Product",
"id":"https://example.com/raspberrypi4",
"name":"Raspberry Pi 4",
"price":"49"
...
}电源
{
"@context":"http://schema.org/",
"@type":"Product",
"name":"Power Supply",
"image":[
"psu.jpg",
"psu-2.jpg"
],
"description":"Power Supply ...",
"offers":{
"@type":"AggregateOffer",
"offerCount":1,
"highPrice":"8.00 ",
"lowPrice":"8.00 ",
"priceCurrency":"EUR",
"offers":[
{
"@type":"Offer",
"priceCurrency":"EUR",
"priceValidUntil":"2019-11-09T21:50:32+01:00",
"url":"powersupply",
"price":"8.00 ",
"itemCondition":"http://schema.org/New",
"availability":"http://schema.org/InStock"
}
]
},
"isConsumableFor":{
"@type":"Product",
"name":"Raspberry Pi 4",
"id":"https://example.com/raspberrypi4",
"offers":[{
"@type":"Offer",
"price":"49"
}]
}
}正如您所看到的,因为isConsumableFor需要一个Product ( Product仍然需要offers、Review或aggregateRating ),所以您至少需要提供其中一个属性(在本例中,我在price中使用Offer )。
不幸的是,isConsumableFor并不是很好的文档化的论schema.org --在本文撰写之时--这个问题实际上在该属性的前四名Google结果中。
就我个人而言,我觉得嵌套的Offer/aggregateRating/Review.需要一个id或url应该可以满足对Product的要求。我认为这是因为Schema一直在增长。
尽管如此,更大的问题可能是--您使用这个架构是为了什么?如果你想用它来改进谷歌的结果--我个人认为无论你如何使用它,你都找不到多少好处。如果您试图通过JSON通过另一个系统连接您的数据,那么我不会太认真地对待结构化数据测试工具。
https://stackoverflow.com/questions/58575621
复制相似问题