JSON-LD
With the JSON-LD format, you can describe content using the objects of the Linked Data (LD) vocabulary. This markup makes the information machine-readable. For JSON-LD data to be automatically processed on the page, put the data inside a script
tag.
You can use this validator to check your JSON-LD markup.
Information marked up with JSON-LD is used:
- By Yandex Mail.
- For creating breadcrumbs that are displayed in search result snippets.
- For structuring questions and answers in mobile search results.
Like JSON data, any JSON-LD data consists of key-value pairs. Unlike JSON, the JSON-LD format features reserved keys that can be used to define the description context or link objects in different ways. For example, "@context" defines the object vocabulary, and "@type" defines the type of the described entity. You can find the full list of reserved keys in the official JSON-LD documentation.
All JSON-LD keys and values without exception are case-sensitive.
Fundamental concepts inherited from JSON:
-
JSON object: A set of comma-separated key-value pairs (zero or more) enclosed in curly brackets. In contrast to JSON, there can't be duplicate key names within the same JSON-LD object.
-
Array: A set of comma-separated values enclosed in square brackets. In contrast to JSON, an array is unordered unless specifically defined otherwise.
-
String: A sequence of Unicode characters enclosed in double quotes. Backslashes (\) can be used to escape characters if necessary.
-
Number: Used in the same way as in most programming languages, but the octal and hexadecimal formats are not supported, and leading zeros are not allowed.
-
true and false: Binary values that can be used for keys with only two possible values (for example, indicating whether the flight is direct or not, whether the passenger is checked in or not, and so on).
-
null: The absence of a value. It's typically used to clear data. If the
@value
,@list
, or@set
key is set tonull
within a JSON object, that entire object is ignored.
Example of markup use in airline emails
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "FlightReservation",
"reservationId": "RXJ34P"
}
</script>
There are three keys in the example:
@context
(reserved) indicates that the object uses the Schema.org vocabulary.@type
(reserved) is set to the FlightReservation type, whose properties can be used to specify flight booking information.reservationId
corresponds to the reservationId property of the FlightReservation type and contains the booking number.
For more examples of using this format, see the article about marking up emails with airline ticket information.