title: Navigating Multi-Dimensional JSON arrays in Python
body: <p>I'm trying to figure out how to query a JSON array in Python. Could someone show me how to do a simple search and print through a fairly complex array please?</p>
  
  <p>The example I'm using is here: <a href="http://eu.battle.net/api/wow/realm/status">http://eu.battle.net/api/wow/realm/status</a></p>
  
  <p>I'd like to see, for example, how to find the 'Silvermoon' server, and print say its 'population', then the 'controlling-faction' within the 'Wintergrasp' array.</p>
  
  <p>The array snippet currently looks like this: </p>
  
  <pre><code>{"type":"pve","population":"high","queue":false,"wintergrasp":{"area":1,"controlling-faction":0,"status":0,"next":1382350068792},"tol-barad":{"area":21,"controlling-faction":0,"status":0,"next":1382349141932},"status":true,"name":"Silvermoon","slug":"silvermoon","battlegroup":"Cyclone / Wirbelsturm","locale":"en_GB","timezone":"Europe/Paris"}
  </code></pre>
  
  <p>At the moment I can access the main array, but don't seem to be able to access sub-arrays without copying the whole thing to another new variable which seems wasteful. I'd like to be able to do something like </p>
  
  <pre><code>import urllib2
  import json
  
  req = urllib2.Request("http://eu.battle.net/api/wow/realm/status", None, {})
  opener = urllib2.build_opener()
  f = opener.open(req)
  
  x = json.load(f)  # open the file and read into a variable
  
  # search and find the Silvermoon server
  silvermoon_array = ????
  
  # print the population
  print silvermoon_array.????
  
  # access the Wintergrasp sub-array
  wintergrasp_sub = ????
  print wintergrasp_sub.????  # print the controlling-faction variable
  </code></pre>
  
  <p>This would really help me get to grips with how to access other things. </p>