如何在此对象数组中返回我想要的内容?

时间:2015-06-10 06:46:17

标签: jquery github-api

所以我正在为练习项目重新创建一个gitHub配置文件,我从下面列出的API中获取了一个repos列表。

我可以用这个jquery替换我想要的内容:

$.getJSON("../../api/github/users/octocat/octocatRepos.json")
  .then(function(octocat){

    $spoon = $('#spoon a');
    $spoon.attr('href', octocat[4].html_url);
    $spoon.text(octocat[4].name)
  });

但显然这对于​​整个repos列表来说要做很多工作,是否有一个数组方法可以用来挑选我想要的各个值并将它放在我需要的位置?

[
  {
    "id": 18221276,
    "name": "git-consortium",
    "full_name": "octocat/git-consortium",
    "owner": {
      "login": "octocat",
      "id": 583231,
      "avatar_url": "https://avatars.githubusercontent.com/u/583231?v=3",
      "gravatar_id": "",
      "url": "https://api.github.com/users/octocat",
      "html_url": "https://github.com/octocat",
      "followers_url": "https://api.github.com/users/octocat/followers",
      "following_url": "https://api.github.com/users/octocat/following{/other_user}",
      "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
      "organizations_url": "https://api.github.com/users/octocat/orgs",
      "repos_url": "https://api.github.com/users/octocat/repos",
      "events_url": "https://api.github.com/users/octocat/events{/privacy}",
      "received_events_url": "https://api.github.com/users/octocat/received_events",
      "type": "User",
      "site_admin": false
    },
    "private": false,
    "html_url": "https://github.com/octocat/git-consortium",
    "description": "This repo is for demonstration purposes only.",
    "fork": false,
    "url": "https://api.github.com/repos/octocat/git-consortium",
    "forks_url": "https://api.github.com/repos/octocat/git-consortium/forks",
    "keys_url": "https://api.github.com/repos/octocat/git-consortium/keys{/key_id}",
    "collaborators_url": "https://api.github.com/repos/octocat/git-consortium/collaborators{/collaborator}",
    "teams_url": "https://api.github.com/repos/octocat/git-consortium/teams",
    "hooks_url": "https://api.github.com/repos/octocat/git-consortium/hooks",
    "issue_events_url": "https://api.github.com/repos/octocat/git-consortium/issues/events{/number}",
    "events_url": "https://api.github.com/repos/octocat/git-consortium/events",
    "assignees_url": "https://api.github.com/repos/octocat/git-consortium/assignees{/user}",
    "branches_url": "https://api.github.com/repos/octocat/git-consortium/branches{/branch}",
    "tags_url": "https://api.github.com/repos/octocat/git-consortium/tags",
    "blobs_url": "https://api.github.com/repos/octocat/git-consortium/git/blobs{/sha}",
    "git_tags_url": "https://api.github.com/repos/octocat/git-consortium/git/tags{/sha}",
    "git_refs_url": "https://api.github.com/repos/octocat/git-consortium/git/refs{/sha}",
    "trees_url": "https://api.github.com/repos/octocat/git-consortium/git/trees{/sha}",
    "statuses_url": "https://api.github.com/repos/octocat/git-consortium/statuses/{sha}",
    "languages_url": "https://api.github.com/repos/octocat/git-consortium/languages",
    "stargazers_url": "https://api.github.com/repos/octocat/git-consortium/stargazers",
    "contributors_url": "https://api.github.com/repos/octocat/git-consortium/contributors",
    "subscribers_url": "https://api.github.com/repos/octocat/git-consortium/subscribers",
    "subscription_url": "https://api.github.com/repos/octocat/git-consortium/subscription",
    "commits_url": "https://api.github.com/repos/octocat/git-consortium/commits{/sha}",
    "git_commits_url": "https://api.github.com/repos/octocat/git-consortium/git/commits{/sha}",
    "comments_url": "https://api.github.com/repos/octocat/git-consortium/comments{/number}",
    "issue_comment_url": "https://api.github.com/repos/octocat/git-consortium/issues/comments{/number}",
    "contents_url": "https://api.github.com/repos/octocat/git-consortium/contents/{+path}",
    "compare_url": "https://api.github.com/repos/octocat/git-consortium/compare/{base}...{head}",
    "merges_url": "https://api.github.com/repos/octocat/git-consortium/merges",
    "archive_url": "https://api.github.com/repos/octocat/git-consortium/{archive_format}{/ref}",
    "downloads_url": "https://api.github.com/repos/octocat/git-consortium/downloads",
    "issues_url": "https://api.github.com/repos/octocat/git-consortium/issues{/number}",
    "pulls_url": "https://api.github.com/repos/octocat/git-consortium/pulls{/number}",
    "milestones_url": "https://api.github.com/repos/octocat/git-consortium/milestones{/number}",
    "notifications_url": "https://api.github.com/repos/octocat/git-consortium/notifications{?since,all,participating}",
    "labels_url": "https://api.github.com/repos/octocat/git-consortium/labels{/name}",
    "releases_url": "https://api.github.com/repos/octocat/git-consortium/releases{/id}",
    "created_at": "2014-03-28T17:55:38Z",
    "updated_at": "2015-04-29T04:45:09Z",
    "pushed_at": "2015-04-29T03:51:55Z",
    "git_url": "git://github.com/octocat/git-consortium.git",
    "ssh_url": "git@github.com:octocat/git-consortium.git",
    "clone_url": "https://github.com/octocat/git-consortium.git",
    "svn_url": "https://github.com/octocat/git-consortium",
    "homepage": null,
    "size": 207,
    "stargazers_count": 5,
    "watchers_count": 5,
    "language": null,
    "has_issues": true,
    "has_downloads": true,
    "has_wiki": true,
    "has_pages": false,
    "forks_count": 5,
    "mirror_url": null,
    "open_issues_count": 1,
    "forks": 5,
    "open_issues": 1,
    "watchers": 5,
    "default_branch": "master"
  },
  {
    "id": 20978623,
    "name": "hello-worId",
    "full_name": "octocat/hello-worId",
    "owner": {
      "login": "octocat",
      "id": 583231,
      "avatar_url": "https://avatars.githubusercontent.com/u/583231?v=3",
      "gravatar_id": "",
      "url": "https://api.github.com/users/octocat",
      "html_url": "https://github.com/octocat",
      "followers_url": "https://api.github.com/users/octocat/followers",
      "following_url": "https://api.github.com/users/octocat/following{/other_user}",
      "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
      "organizations_url": "https://api.github.com/users/octocat/orgs",
      "repos_url": "https://api.github.com/users/octocat/repos",
      "events_url": "https://api.github.com/users/octocat/events{/privacy}",
      "received_events_url": "https://api.github.com/users/octocat/received_events",
      "type": "User",
      "site_admin": false
    },
    "private": false,
    "html_url": "https://github.com/octocat/hello-worId",
    "description": "My first repository on GitHub.",
    "fork": false,
    "url": "https://api.github.com/repos/octocat/hello-worId",
    "forks_url": "https://api.github.com/repos/octocat/hello-worId/forks",
    "keys_url": "https://api.github.com/repos/octocat/hello-worId/keys{/key_id}",
    "collaborators_url": "https://api.github.com/repos/octocat/hello-worId/collaborators{/collaborator}",
    "teams_url": "https://api.github.com/repos/octocat/hello-worId/teams",
    "hooks_url": "https://api.github.com/repos/octocat/hello-worId/hooks",
    "issue_events_url": "https://api.github.com/repos/octocat/hello-worId/issues/events{/number}",
    "events_url": "https://api.github.com/repos/octocat/hello-worId/events",
    "assignees_url": "https://api.github.com/repos/octocat/hello-worId/assignees{/user}",
    "branches_url": "https://api.github.com/repos/octocat/hello-worId/branches{/branch}",
    "tags_url": "https://api.github.com/repos/octocat/hello-worId/tags",
    "blobs_url": "https://api.github.com/repos/octocat/hello-worId/git/blobs{/sha}",
    "git_tags_url": "https://api.github.com/repos/octocat/hello-worId/git/tags{/sha}",
    "git_refs_url": "https://api.github.com/repos/octocat/hello-worId/git/refs{/sha}",
    "trees_url": "https://api.github.com/repos/octocat/hello-worId/git/trees{/sha}",
    "statuses_url": "https://api.github.com/repos/octocat/hello-worId/statuses/{sha}",
    "languages_url": "https://api.github.com/repos/octocat/hello-worId/languages",
    "stargazers_url": "https://api.github.com/repos/octocat/hello-worId/stargazers",
    "contributors_url": "https://api.github.com/repos/octocat/hello-worId/contributors",
    "subscribers_url": "https://api.github.com/repos/octocat/hello-worId/subscribers",
    "subscription_url": "https://api.github.com/repos/octocat/hello-worId/subscription",
    "commits_url": "https://api.github.com/repos/octocat/hello-worId/commits{/sha}",
    "git_commits_url": "https://api.github.com/repos/octocat/hello-worId/git/commits{/sha}",
    "comments_url": "https://api.github.com/repos/octocat/hello-worId/comments{/number}",
    "issue_comment_url": "https://api.github.com/repos/octocat/hello-worId/issues/comments{/number}",
    "contents_url": "https://api.github.com/repos/octocat/hello-worId/contents/{+path}",
    "compare_url": "https://api.github.com/repos/octocat/hello-worId/compare/{base}...{head}",
    "merges_url": "https://api.github.com/repos/octocat/hello-worId/merges",
    "archive_url": "https://api.github.com/repos/octocat/hello-worId/{archive_format}{/ref}",
    "downloads_url": "https://api.github.com/repos/octocat/hello-worId/downloads",
    "issues_url": "https://api.github.com/repos/octocat/hello-worId/issues{/number}",
    "pulls_url": "https://api.github.com/repos/octocat/hello-worId/pulls{/number}",
    "milestones_url": "https://api.github.com/repos/octocat/hello-worId/milestones{/number}",
    "notifications_url": "https://api.github.com/repos/octocat/hello-worId/notifications{?since,all,participating}",
    "labels_url": "https://api.github.com/repos/octocat/hello-worId/labels{/name}",
    "releases_url": "https://api.github.com/repos/octocat/hello-worId/releases{/id}",
    "created_at": "2014-06-18T21:26:19Z",
    "updated_at": "2015-03-24T10:34:50Z",
    "pushed_at": "2014-06-18T21:26:19Z",
    "git_url": "git://github.com/octocat/hello-worId.git",
    "ssh_url": "git@github.com:octocat/hello-worId.git",
    "clone_url": "https://github.com/octocat/hello-worId.git",
    "svn_url": "https://github.com/octocat/hello-worId",
    "homepage": null,
    "size": 104,
    "stargazers_count": 10,
    "watchers_count": 10,
    "language": null,
    "has_issues": true,
    "has_downloads": true,
    "has_wiki": true,
    "has_pages": false,
    "forks_count": 16,
    "mirror_url": null,
    "open_issues_count": 1,
    "forks": 16,
    "open_issues": 1,
    "watchers": 10,
    "default_branch": "master"
  },
  {
    "id": 1296269,
    "name": "Hello-World",
    "full_name": "octocat/Hello-World",
    "owner": {
      "login": "octocat",
      "id": 583231,
      "avatar_url": "https://avatars.githubusercontent.com/u/583231?v=3",
      "gravatar_id": "",
      "url": "https://api.github.com/users/octocat",
      "html_url": "https://github.com/octocat",
      "followers_url": "https://api.github.com/users/octocat/followers",
      "following_url": "https://api.github.com/users/octocat/following{/other_user}",
      "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
      "organizations_url": "https://api.github.com/users/octocat/orgs",
      "repos_url": "https://api.github.com/users/octocat/repos",
      "events_url": "https://api.github.com/users/octocat/events{/privacy}",
      "received_events_url": "https://api.github.com/users/octocat/received_events",
      "type": "User",
      "site_admin": false
    },
    "private": false,
    "html_url": "https://github.com/octocat/Hello-World",
    "description": "This your first repo!",
    "fork": false,
    "url": "https://api.github.com/repos/octocat/Hello-World",
    "forks_url": "https://api.github.com/repos/octocat/Hello-World/forks",
    "keys_url": "https://api.github.com/repos/octocat/Hello-World/keys{/key_id}",
    "collaborators_url": "https://api.github.com/repos/octocat/Hello-World/collaborators{/collaborator}",
    "teams_url": "https://api.github.com/repos/octocat/Hello-World/teams",
    "hooks_url": "https://api.github.com/repos/octocat/Hello-World/hooks",
    "issue_events_url": "https://api.github.com/repos/octocat/Hello-World/issues/events{/number}",
    "events_url": "https://api.github.com/repos/octocat/Hello-World/events",
    "assignees_url": "https://api.github.com/repos/octocat/Hello-World/assignees{/user}",
    "branches_url": "https://api.github.com/repos/octocat/Hello-World/branches{/branch}",
    "tags_url": "https://api.github.com/repos/octocat/Hello-World/tags",
    "blobs_url": "https://api.github.com/repos/octocat/Hello-World/git/blobs{/sha}",
    "git_tags_url": "https://api.github.com/repos/octocat/Hello-World/git/tags{/sha}",
    "git_refs_url": "https://api.github.com/repos/octocat/Hello-World/git/refs{/sha}",
    "trees_url": "https://api.github.com/repos/octocat/Hello-World/git/trees{/sha}",
    "statuses_url": "https://api.github.com/repos/octocat/Hello-World/statuses/{sha}",
    "languages_url": "https://api.github.com/repos/octocat/Hello-World/languages",
    "stargazers_url": "https://api.github.com/repos/octocat/Hello-World/stargazers",
    "contributors_url": "https://api.github.com/repos/octocat/Hello-World/contributors",
    "subscribers_url": "https://api.github.com/repos/octocat/Hello-World/subscribers",
    "subscription_url": "https://api.github.com/repos/octocat/Hello-World/subscription",
    "commits_url": "https://api.github.com/repos/octocat/Hello-World/commits{/sha}",
    "git_commits_url": "https://api.github.com/repos/octocat/Hello-World/git/commits{/sha}",
    "comments_url": "https://api.github.com/repos/octocat/Hello-World/comments{/number}",
    "issue_comment_url": "https://api.github.com/repos/octocat/Hello-World/issues/comments{/number}",
    "contents_url": "https://api.github.com/repos/octocat/Hello-World/contents/{+path}",
    "compare_url": "https://api.github.com/repos/octocat/Hello-World/compare/{base}...{head}",
    "merges_url": "https://api.github.com/repos/octocat/Hello-World/merges",
    "archive_url": "https://api.github.com/repos/octocat/Hello-World/{archive_format}{/ref}",
    "downloads_url": "https://api.github.com/repos/octocat/Hello-World/downloads",
    "issues_url": "https://api.github.com/repos/octocat/Hello-World/issues{/number}",
    "pulls_url": "https://api.github.com/repos/octocat/Hello-World/pulls{/number}",
    "milestones_url": "https://api.github.com/repos/octocat/Hello-World/milestones{/number}",
    "notifications_url": "https://api.github.com/repos/octocat/Hello-World/notifications{?since,all,participating}",
    "labels_url": "https://api.github.com/repos/octocat/Hello-World/labels{/name}",
    "releases_url": "https://api.github.com/repos/octocat/Hello-World/releases{/id}",
    "created_at": "2011-01-26T19:01:12Z",
    "updated_at": "2015-06-06T04:52:21Z",
    "pushed_at": "2015-05-10T09:06:45Z",
    "git_url": "git://github.com/octocat/Hello-World.git",
    "ssh_url": "git@github.com:octocat/Hello-World.git",
    "clone_url": "https://github.com/octocat/Hello-World.git",
    "svn_url": "https://github.com/octocat/Hello-World",
    "homepage": "",
    "size": 643,
    "stargazers_count": 1404,
    "watchers_count": 1404,
    "language": null,
    "has_issues": true,
    "has_downloads": true,
    "has_wiki": true,
    "has_pages": false,
    "forks_count": 1106,
    "mirror_url": null,
    "open_issues_count": 132,
    "forks": 1106,
    "open_issues": 132,
    "watchers": 1404,
    "default_branch": "master"
  },
  {
    "id": 17881631,
    "name": "octocat.github.io",
    "full_name": "octocat/octocat.github.io",
    "owner": {
      "login": "octocat",
      "id": 583231,
      "avatar_url": "https://avatars.githubusercontent.com/u/583231?v=3",
      "gravatar_id": "",
      "url": "https://api.github.com/users/octocat",
      "html_url": "https://github.com/octocat",
      "followers_url": "https://api.github.com/users/octocat/followers",
      "following_url": "https://api.github.com/users/octocat/following{/other_user}",
      "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
      "organizations_url": "https://api.github.com/users/octocat/orgs",
      "repos_url": "https://api.github.com/users/octocat/repos",
      "events_url": "https://api.github.com/users/octocat/events{/privacy}",
      "received_events_url": "https://api.github.com/users/octocat/received_events",
      "type": "User",
      "site_admin": false
    },
    "private": false,
    "html_url": "https://github.com/octocat/octocat.github.io",
    "description": "",
    "fork": false,
    "url": "https://api.github.com/repos/octocat/octocat.github.io",
    "forks_url": "https://api.github.com/repos/octocat/octocat.github.io/forks",
    "keys_url": "https://api.github.com/repos/octocat/octocat.github.io/keys{/key_id}",
    "collaborators_url": "https://api.github.com/repos/octocat/octocat.github.io/collaborators{/collaborator}",
    "teams_url": "https://api.github.com/repos/octocat/octocat.github.io/teams",
    "hooks_url": "https://api.github.com/repos/octocat/octocat.github.io/hooks",
    "issue_events_url": "https://api.github.com/repos/octocat/octocat.github.io/issues/events{/number}",
    "events_url": "https://api.github.com/repos/octocat/octocat.github.io/events",
    "assignees_url": "https://api.github.com/repos/octocat/octocat.github.io/assignees{/user}",
    "branches_url": "https://api.github.com/repos/octocat/octocat.github.io/branches{/branch}",
    "tags_url": "https://api.github.com/repos/octocat/octocat.github.io/tags",
    "blobs_url": "https://api.github.com/repos/octocat/octocat.github.io/git/blobs{/sha}",
    "git_tags_url": "https://api.github.com/repos/octocat/octocat.github.io/git/tags{/sha}",
    "git_refs_url": "https://api.github.com/repos/octocat/octocat.github.io/git/refs{/sha}",
    "trees_url": "https://api.github.com/repos/octocat/octocat.github.io/git/trees{/sha}",
    "statuses_url": "https://api.github.com/repos/octocat/octocat.github.io/statuses/{sha}",
    "languages_url": "https://api.github.com/repos/octocat/octocat.github.io/languages",
    "stargazers_url": "https://api.github.com/repos/octocat/octocat.github.io/stargazers",
    "contributors_url": "https://api.github.com/repos/octocat/octocat.github.io/contributors",
    "subscribers_url": "https://api.github.com/repos/octocat/octocat.github.io/subscribers",
    "subscription_url": "https://api.github.com/repos/octocat/octocat.github.io/subscription",
    "commits_url": "https://api.github.com/repos/octocat/octocat.github.io/commits{/sha}",
    "git_commits_url": "https://api.github.com/repos/octocat/octocat.github.io/git/commits{/sha}",
    "comments_url": "https://api.github.com/repos/octocat/octocat.github.io/comments{/number}",
    "issue_comment_url": "https://api.github.com/repos/octocat/octocat.github.io/issues/comments{/number}",
    "contents_url": "https://api.github.com/repos/octocat/octocat.github.io/contents/{+path}",
    "compare_url": "https://api.github.com/repos/octocat/octocat.github.io/compare/{base}...{head}",
    "merges_url": "https://api.github.com/repos/octocat/octocat.github.io/merges",
    "archive_url": "https://api.github.com/repos/octocat/octocat.github.io/{archive_format}{/ref}",
    "downloads_url": "https://api.github.com/repos/octocat/octocat.github.io/downloads",
    "issues_url": "https://api.github.com/repos/octocat/octocat.github.io/issues{/number}",
    "pulls_url": "https://api.github.com/repos/octocat/octocat.github.io/pulls{/number}",
    "milestones_url": "https://api.github.com/repos/octocat/octocat.github.io/milestones{/number}",
    "notifications_url": "https://api.github.com/repos/octocat/octocat.github.io/notifications{?since,all,participating}",
    "labels_url": "https://api.github.com/repos/octocat/octocat.github.io/labels{/name}",
    "releases_url": "https://api.github.com/repos/octocat/octocat.github.io/releases{/id}",
    "created_at": "2014-03-18T20:54:39Z",
    "updated_at": "2015-05-18T08:18:06Z",
    "pushed_at": "2014-04-27T10:06:40Z",
    "git_url": "git://github.com/octocat/octocat.github.io.git",
    "ssh_url": "git@github.com:octocat/octocat.github.io.git",
    "clone_url": "https://github.com/octocat/octocat.github.io.git",
    "svn_url": "https://github.com/octocat/octocat.github.io",
    "homepage": null,
    "size": 168,
    "stargazers_count": 8,
    "watchers_count": 8,
    "language": "CSS",
    "has_issues": true,
    "has_downloads": true,
    "has_wiki": true,
    "has_pages": true,
    "forks_count": 12,
    "mirror_url": null,
    "open_issues_count": 3,
    "forks": 12,
    "open_issues": 3,
    "watchers": 8,
    "default_branch": "master"
  },
  {
    "id": 1300192,
    "name": "Spoon-Knife",
    "full_name": "octocat/Spoon-Knife",
    "owner": {
      "login": "octocat",
      "id": 583231,
      "avatar_url": "https://avatars.githubusercontent.com/u/583231?v=3",
      "gravatar_id": "",
      "url": "https://api.github.com/users/octocat",
      "html_url": "https://github.com/octocat",
      "followers_url": "https://api.github.com/users/octocat/followers",
      "following_url": "https://api.github.com/users/octocat/following{/other_user}",
      "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
      "organizations_url": "https://api.github.com/users/octocat/orgs",
      "repos_url": "https://api.github.com/users/octocat/repos",
      "events_url": "https://api.github.com/users/octocat/events{/privacy}",
      "received_events_url": "https://api.github.com/users/octocat/received_events",
      "type": "User",
      "site_admin": false
    },
    "private": false,
    "html_url": "https://github.com/octocat/Spoon-Knife",
    "description": "This repo is for demonstration purposes only.",
    "fork": false,
    "url": "https://api.github.com/repos/octocat/Spoon-Knife",
    "forks_url": "https://api.github.com/repos/octocat/Spoon-Knife/forks",
    "keys_url": "https://api.github.com/repos/octocat/Spoon-Knife/keys{/key_id}",
    "collaborators_url": "https://api.github.com/repos/octocat/Spoon-Knife/collaborators{/collaborator}",
    "teams_url": "https://api.github.com/repos/octocat/Spoon-Knife/teams",
    "hooks_url": "https://api.github.com/repos/octocat/Spoon-Knife/hooks",
    "issue_events_url": "https://api.github.com/repos/octocat/Spoon-Knife/issues/events{/number}",
    "events_url": "https://api.github.com/repos/octocat/Spoon-Knife/events",
    "assignees_url": "https://api.github.com/repos/octocat/Spoon-Knife/assignees{/user}",
    "branches_url": "https://api.github.com/repos/octocat/Spoon-Knife/branches{/branch}",
    "tags_url": "https://api.github.com/repos/octocat/Spoon-Knife/tags",
    "blobs_url": "https://api.github.com/repos/octocat/Spoon-Knife/git/blobs{/sha}",
    "git_tags_url": "https://api.github.com/repos/octocat/Spoon-Knife/git/tags{/sha}",
    "git_refs_url": "https://api.github.com/repos/octocat/Spoon-Knife/git/refs{/sha}",
    "trees_url": "https://api.github.com/repos/octocat/Spoon-Knife/git/trees{/sha}",
    "statuses_url": "https://api.github.com/repos/octocat/Spoon-Knife/statuses/{sha}",
    "languages_url": "https://api.github.com/repos/octocat/Spoon-Knife/languages",
    "stargazers_url": "https://api.github.com/repos/octocat/Spoon-Knife/stargazers",
    "contributors_url": "https://api.github.com/repos/octocat/Spoon-Knife/contributors",
    "subscribers_url": "https://api.github.com/repos/octocat/Spoon-Knife/subscribers",
    "subscription_url": "https://api.github.com/repos/octocat/Spoon-Knife/subscription",
    "commits_url": "https://api.github.com/repos/octocat/Spoon-Knife/commits{/sha}",
    "git_commits_url": "https://api.github.com/repos/octocat/Spoon-Knife/git/commits{/sha}",
    "comments_url": "https://api.github.com/repos/octocat/Spoon-Knife/comments{/number}",
    "issue_comment_url": "https://api.github.com/repos/octocat/Spoon-Knife/issues/comments{/number}",
    "contents_url": "https://api.github.com/repos/octocat/Spoon-Knife/contents/{+path}",
    "compare_url": "https://api.github.com/repos/octocat/Spoon-Knife/compare/{base}...{head}",
    "merges_url": "https://api.github.com/repos/octocat/Spoon-Knife/merges",
    "archive_url": "https://api.github.com/repos/octocat/Spoon-Knife/{archive_format}{/ref}",
    "downloads_url": "https://api.github.com/repos/octocat/Spoon-Knife/downloads",
    "issues_url": "https://api.github.com/repos/octocat/Spoon-Knife/issues{/number}",
    "pulls_url": "https://api.github.com/repos/octocat/Spoon-Knife/pulls{/number}",
    "milestones_url": "https://api.github.com/repos/octocat/Spoon-Knife/milestones{/number}",
    "notifications_url": "https://api.github.com/repos/octocat/Spoon-Knife/notifications{?since,all,participating}",
    "labels_url": "https://api.github.com/repos/octocat/Spoon-Knife/labels{/name}",
    "releases_url": "https://api.github.com/repos/octocat/Spoon-Knife/releases{/id}",
    "created_at": "2011-01-27T19:30:43Z",
    "updated_at": "2015-06-08T14:33:58Z",
    "pushed_at": "2015-06-08T18:23:59Z",
    "git_url": "git://github.com/octocat/Spoon-Knife.git",
    "ssh_url": "git@github.com:octocat/Spoon-Knife.git",
    "clone_url": "https://github.com/octocat/Spoon-Knife.git",
    "svn_url": "https://github.com/octocat/Spoon-Knife",
    "homepage": "",
    "size": 43296,
    "stargazers_count": 9771,
    "watchers_count": 9771,
    "language": "CSS",
    "has_issues": true,
    "has_downloads": true,
    "has_wiki": true,
    "has_pages": false,
    "forks_count": 59925,
    "mirror_url": null,
    "open_issues_count": 4741,
    "forks": 59925,
    "open_issues": 4741,
    "watchers": 9771,
    "default_branch": "master"
  }
]

1 个答案:

答案 0 :(得分:0)

<script>
 $.getJSON("json",function(octocat){
    $spoon = $('#spoon a');
    $spoon.attr('href', octocat[4].html_url);
    $spoon.text(octocat[4].name)
  });
</script>