Included data for an array of articles


#1

Say I have an array of article resources in a compound document. Is this the right way to have the included resources?
Also, suppose I need to display all the articles along with title and the author’s name as a list. How do I access the author’s name for all the articles to display at once?

{
  "data": [{
    "type": "articles",
    "id": "1",
    "attributes": {
      "title": "JSON API paints my bikeshed!"
    },
    "links": {
      "self": "http://example.com/articles/1"
    },
    "relationships": {
      "author": {
        "links": {
          "self": "http://example.com/articles/1/relationships/author",
          "related": "http://example.com/articles/1/author"
        },
        "data": { "type": "people", "id": "9" }
      },
      "comments": {
        "links": {
          "self": "http://example.com/articles/1/relationships/comments",
          "related": "http://example.com/articles/1/comments"
        },
        "data": [
          { "type": "comments", "id": "5" },
          { "type": "comments", "id": "12" }
        ]
      }
    }
  },
 {
"type": "articles",
    "id": "2",
    "attributes": {
      "title": "second article!"
    },
    "links": {
      "self": "http://example.com/articles/2"
    },
    "relationships": {
      "author": {
        "links": {
          "self": "http://example.com/articles/2/relationships/author",
          "related": "http://example.com/articles/2/author"
        },
        "data": { "type": "people", "id": "11" }
      },
      "comments": {
        "links": {
          "self": "http://example.com/articles/2/relationships/comments",
          "related": "http://example.com/articles/2/comments"
        },
        "data": [
          { "type": "comments", "id": "7" }
        ]
      }
    }
}],
  "included": [{
    "type": "people",
    "id": "9",
    "attributes": {
      "first-name": "Dan",
      "last-name": "Gebhardt",
      "twitter": "dgeb"
    },
    "links": {
      "self": "http://example.com/people/9"
    }
  }, {
    "type": "comments",
    "id": "5",
    "attributes": {
      "body": "First!"
    },
    "relationships": {
      "author": {
        "data": { "type": "people", "id": "2" }
      }
    },
    "links": {
      "self": "http://example.com/comments/5"
    }
  }, {
    "type": "comments",
    "id": "12",
    "attributes": {
      "body": "I like XML better"
    },
    "relationships": {
      "author": {
        "data": { "type": "people", "id": "9" }
      }
    },
    "links": {
      "self": "http://example.com/comments/12"
    }
  },
{
    "type": "people",
    "id": "11",
    "attributes": {
      "first-name": "John",
      "last-name": "Penn",
      "twitter": "jpenn"
    },
    "links": {
      "self": "http://example.com/people/11"
    }
  },
{
    "type": "comments",
    "id": "7",
    "attributes": {
      "body": "I like json better"
    },
    "relationships": {
      "author": {
        "data": { "type": "people", "id": "11" }
      }
    },
    "links": {
      "self": "http://example.com/comments/7"
    }
  }
]
}

#2

/articles?include=author&fields[author]=name according to this