Question

I'm wondering if microdata has a support for typed lists. I'm trying to do the following:

<div itemscope itemtype="http://example/Person">
    <span itemprop="name">Charlie</span>    
    <span itemprop="address">...</span>
    <ul itemprop="Friends">
       <li itemscope itemtype="http://example/Person">
           <span itemprop="name">Dennis</span>
           <span itemprop="address">...</span>
       </li>
       <li itemscope itemtype="http://example/Person">
           <span itemprop="name">Mac</span>
           <span itemprop="address">...</span>
       </li>
    </ul>
</div>

But it gets parsed as:

 {
    "items": [
        {
          "type": [
            "http://example/Person"
          ],
          "properties": {
            "name": [
              "Charlie"
            ],
            "address": [
              "..."
            ],
            "Friends": [
              "\n\t\t\n\t\t\tDennis\n\t\t\t...\n\t\t\n\t\t\n\t\t\tMac\n\t\t\t...\n\t\t\n\t"
            ]
          }
        },
        {
          "type": [
            "http://example/Person"
          ],
          "properties": {
            "name": [
              "Dennis"
            ],
            "address": [
              "..."
            ]
          }
        },
        {
          "type": [
            "http://example/Person"
          ],
          "properties": {
            "name": [
              "Mac"
            ],
            "address": [
              "..."
            ]
          }
        }
    ]
 }

When I expect to prop "Friends" to have an array of "Person" objects.

Was it helpful?

Solution

I’m not sure if I get "array" or "typed list", but maybe you could specify the property on each item? (FWIW, that’s how Schema.org does it usually.)

<div itemscope itemtype="http://example/Person">
    <ul> <!-- using "friend" instead of "Friends" -->
       <li itemprop="friend" itemscope itemtype="http://example/Person"></li>
       <li itemprop="friend" itemscope itemtype="http://example/Person"></li>
    </ul>
</div>

If there is a "list of friends", possibly ordered, maybe you could use a special list item? (FWIW, Schema.org has ItemList.)

<div itemscope itemtype="http://example/Person">
    <ul itemprop="hasFriendList" itemscope itemtype="http://example/FriendList">
       <li itemprop="friend" itemscope itemtype="http://example/Person"></li>
       <li itemprop="friend" itemscope itemtype="http://example/Person"></li>
    </ul>
</div>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top