Skip to content

Native support for schema:ListItem #595

@gkellogg

Description

@gkellogg

Per a suggestion by @danbri, we may want to add a container type, similar to @list for encoding schema:ItemList serializations, when the values are schema:ListItem and order is set through schema:position. ItemList can be used with text values as well, but this is already reasonably supported natively.

Markup might look like the following:

{
  "@context": {
    "@vocab": "http://schema.org/",
    "itemListElement": {"@container": "@listItem"}
  },
  "@type": "ItemList",
  "@url": "http://en.wikipedia.org/wiki/Billboard_200",
  "name": "Top music artists",
  "description": "The artists with the most cumulative weeks at number one according to Billboard 200",
  "itemListElement": [
    {"@type": "MusicGroup", "name": "Beatles"},
    {"@type": "MusicGroup", "name": "Elvis Presley"},
    {"@type": "MusicGroup", "name": "Michael Jackson"},
    {"@type": "MusicGroup", "name": "Garth Brooks" }
  ]

This would expand to the following:

[
  {
    "@id": "http://en.wikipedia.org/wiki/Billboard_200",
    "@type": ["http://schema.org/ItemList"],
    "http://schema.org/description": [{
      "@value": "The artists with the most cumulative weeks at number one according to Billboard 200"
    }],
    "http://schema.org/itemListElement": [{
      "@type": ["http://schema.org/ListItem"],
      "http://schema.org/item": [{
        "@type": ["http://schema.org/MusicGroup"],
        "http://schema.org/name": [{"@value": "Beatles"}]
      }],
      "http://schema.org/position": [{"@value": 1}]
    },  {
      "@type": ["http://schema.org/ListItem"],
      "http://schema.org/item": [{
        "@type": ["http://schema.org/MusicGroup"],
        "http://schema.org/name": [{"@value": "Elvis Presley"}]
      }],
      "http://schema.org/position": [{"@value": 2}]
    }, {
      "@type": ["http://schema.org/ListItem"],
      "http://schema.org/item": [{
        "@type": ["http://schema.org/MusicGroup"],
        "http://schema.org/name": [{"@value": "Michael Jackson"}]
      }],
      "http://schema.org/position": [{"@value": 3}]
    }, {
      "@type": ["http://schema.org/ListItem"],
      "http://schema.org/item": [{
        "@type": ["http://schema.org/MusicGroup"],
        "http://schema.org/name": [{"@value": "Garth Brooks"}]
      }],
      "http://schema.org/position": [{"@value": 3}]
    }
  ],
  "http://schema.org/name": [{"@value": "Top music artists"}]
}]

Otherwise, it works like @list.

When compacting, the processor will re-order items based on position, and ignore any nextItem or previousItem entries.

Expansion shows 1-base position, but could be 0-base as well. Note that specific position values are lost when compacting, and duplicate values may lead to undefined relative ordering.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions