问题
Actually I have a lack of understanding of how Schema.org objects are "composed" out of the given specification. Unfortunately I found no clear explanation so far.
Let’s take the JSON-LD example given at https://schema.org/SoldOut.
In "Example 1" we have given a property offers
of type Offer
. Within the only Offer
, there is a price
property specified ("13.00").
But if I look at the specification of object Offer
given at https://schema.org/Offer there is no price
property specified at all.
So my question is, where does it come from - the price
property?
It seems that the Offer
object merges the types Offer
and PriceSpecification
.
But why isn’t it then mentioned there in the @type
property?
回答1:
There are two kinds of price
-property could be coming:
The first kind is the kind shown in the example of SoldOut
. The second kind i show you in the following example, based on the SoldOut
too
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Event",
"location": {
"@type": "Place",
"address": {
"@type": "PostalAddress",
"addressLocality": "Denver",
"addressRegion": "CO",
"postalCode": "80209",
"streetAddress": "7 S. Broadway"
},
"name": "The Hi-Dive"
},
"name": "SOLD OUT! Typhoon with Radiation City",
"offers": {
"@type": "Offer",
"availability": "http://schema.org/SoldOut",
"price": {
"@type": "PriceSpecification",
"price": "13.00",
"priceCurrency": "USD",
},
"url": "http://www.ticketfly.com/purchase/309433"
},
"startDate": "2013-09-14T21:30"
}
</script>
To say it in words, you could use price
as stand-alone property, or as a part of the type PriceSpecification
too. Both kinds of use are OK, the usage as a part of the type PriceSpecification
is for cases, where you have to specify more properties as only the price and its currency, as listed under https://schema.org/PriceSpecification.
回答2:
But if I look at the specification of object
Offer
given at https://schema.org/Offer there is noprice
property specified at all.
The Offer
type does specify the price
property.
The price
property is listed on https://schema.org/Offer, and the Offer
type is also listed under "Used on these types" on https://schema.org/price.
(Sometimes there’s a bug where a type page doesn’t list all properties, so maybe that’s why you didn’t see it.)
A type always specifies the properties of itself and the properties of all its parent types. So for Offer, you can use the properties from Offer
, from Intangible
, and from Thing
:
Thing
>Intangible
>Offer
All available properties are listed in the first table on the type’s pages (unless the bug hits).
来源:https://stackoverflow.com/questions/51019612/schema-org-and-object-hierarchy