2017-10-28 8 views
-2

HI Jungs Ich möchte im Grunde diese JSON-Daten analysieren.Python: Parsing JSON-Liste

[ 
    { 
     "id": 417862, 
     "name": "octokit.rb", 
     "full_name": "octokit/octokit.rb", 
     "owner": { 
      "login": "octokit", 
      "id": 3430433, 
      "avatar_url": "https://avatars0.githubusercontent.com/u/3430433?v=4", 
      "gravatar_id": "", 
      "url": "https://api.github.com/users/octokit", 
      "html_url": "https://github.com/octokit", 
      "followers_url": "https://api.github.com/users/octokit/followers", 
      "following_url": "https://api.github.com/users/octokit/following{/other_user}", 
      "gists_url": "https://api.github.com/users/octokit/gists{/gist_id}", 
      "starred_url": "https://api.github.com/users/octokit/starred{/owner}{/repo}", 
      "subscriptions_url": 
     } ] 

Meine Frage ist, wie kann ich den Wert von "id": 417862 von json

Dank erhalten.

+0

Welche Programmiersprache/Bibliothek verwenden Sie? –

+0

Ich benutze Python !! – prime

+1

Mögliches Duplikat von [Parsen von Werten aus einer JSON-Datei?] (Https://stackoverflow.com/questions/2835559/parsing-values-from-a-json-file) –

Antwort

0

Wie wäre:

mylist = [{ 
    "id": 417862, 
    "name": "octokit.rb", 
    "full_name": "octokit/octokit.rb", 
    "owner": { 
    "login": "octokit", 
    "id": 3430433, 
    "avatar_url": "https://avatars0.githubusercontent.com/u/3430433?v=4", 
    "gravatar_id": "", 
    "url": "https://api.github.com/users/octokit", 
    "html_url": "https://github.com/octokit", 
    "followers_url": "https://api.github.com/users/octokit/followers", 
    "following_url": "https://api.github.com/users/octokit/following{/other_user}", 
    "gists_url": "https://api.github.com/users/octokit/gists{/gist_id}", 
    "starred_url": "https://api.github.com/users/octokit/starred{/owner}{/repo}", 
    "subscriptions_url": "cats" 
    } 
}] 

print mylist[0]['id'] 

Das gibt druckt das id Attribut des 0-ten (das heißt zuerst) Mitglied des mylist, die 417862 entspricht.