title: How to parse empty JSON property/element in Python
body: <p>I am attempting to parse some JSON that I am receiving from a RESTful API, but I am having trouble accessing the data in Python because it appears that there is an empty property name.</p>
  
  <p>A sample of the JSON returned:</p>
  
  <pre><code>{
    "extractorData" : {
  "url" : "RetreivedDataURL",
  "resourceId" : "e38e1a7dd8f23dffbc77baf2d14ee500",
  "data" : [ {
    "group" : [ {
      "CaseNumber" : [ {
        "text" : "PO-1994-1350",
        "href" : "http://www.referenceURL.net"
      } ],
      "DateFiled" : [ {
        "text" : "03/11/1994"
      } ],
      "CaseDescription" : [ {
        "text" : "Mary v. JONES"
      } ],
      "FoundParty" : [ {
        "text" : "Lastname, MARY BETH (Plaintiff)"
      } ]
    }, {
      "CaseNumber" : [ {
        "text" : "NP-1998-2194",
        "href" : "http://www.referenceURL.net"
      }, {
        "text" : "FD-1998-2310",
        "href" : "http://www.referenceURL.net"
      } ],
      "DateFiled" : [ {
        "text" : "08/13/1993"
      }, {
        "text" : "06/02/1998"
      } ],
      "CaseDescription" : [ {
        "text" : "IN RE: NOTARY PUBLIC VS REDACTED"
      }, {
        "text" : "REDACTED"
      } ],
      "FoundParty" : [ {
        "text" : "Lastname, MARY H (Plaintiff)"
      }, {
        "text" : "Lastname, MARY BETH (Defendant)"
      } ]
    } ]
  } ]
  </code></pre>
  
  <p>And the Python code I am attempting to use</p>
  
  <pre><code>import requests
  import json
  
  FirstName = raw_input("Please Enter First name: ")
  LastName = raw_input("Please Enter Last Name: ")
  
  
  with requests.Session() as c:
  url = ('https://www.requestURL.net/?name={}&amp;lastname={}').format(LastName, FirstName)
  page = c.get(url)
  data = page.content
  
  theJSON = json.loads(data)
  
  def myprint(d):
  stack = d.items()
  while stack:
      k, v = stack.pop()
      if isinstance(v, dict):
          stack.extend(v.iteritems())
      else:
          print("%s: %s" % (k, v))
  
  print myprint(theJSON["extractorData"]["data"]["group"])
  </code></pre>
  
  <p>I get the error:</p>
  
  <pre><code>TypeError: list indices must be integers, not str
  </code></pre>
  
  <p>I am new to parsing Python and more than simple python in general so excuse my ignorance. But what leads me to believe that it is an empty property is that when I use a tool to view the JSON visually online, I get empty brackets, Like so:</p>
  
  <p><a href="https://i.stack.imgur.com/VxEW9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VxEW9.png" alt="printscreen"></a>
  </p>
  
  <p>Any help parsing this data into text would be of great help.</p>
  
  <p>EDIT: Now I am able to reference a certain node with this code:</p>
  
  <pre><code>for d in group:
  print group[0]['CaseNumber'][0]["text"]
  </code></pre>
  
  <p>But now how can I iterate over all the dictionaries listed in the group property to list all the nodes labeled "CaseNumber" because it should exist in every one of them. e.g </p>
  
  <pre><code>print group[0]['CaseNumber'][0]["text"]
  </code></pre>
  
  <p>then</p>
  
  <pre><code>for d in group:
  print group[1]['CaseNumber'][0]["text"]
  </code></pre>
  
  <p>and so on and so forth. Perhaps incrementing some sort of integer until it reaches the end? I am not quite sure.</p>