title: Python - parse multiple json files with differing but known structures
body: <p>Edit:</p>
  
  <p>The answer appears to be:</p>
  
  <pre><code>args = ["whichever", "paths", "are", "needed"]
  
    for x in args
     theJSON = theJSON[x]
  
    target = theJSON
    print(target)
  </code></pre>
  
  <p>I am attempting to parse JSON files with known but varying structures.  I am transitioning into Python, but know that the data can be retrieved when the paths are explicitly defined within the code, such as:</p>
  
  <pre><code>...
  theJSON = json.loads(data)
  target = theJSON["value"]["value2"]["tastydata"]
  print((str)target)
  </code></pre>
  
  <p>However, as the usage expands the values may be the same as the above, but also may have a separate structure such as ["product"]["0"]["result"].</p>
  
  <p>Is there a way for the path values to be saved in a configuration file or similar and then used to dynamically parse based upon that configuration?  I've attempted simply creating an array (with the view of creating such an array with the configuration values if successful) with the values such as:</p>
  
  <pre><code>...
  args = ["value"]["value2"]["tastydata"]
  target = theJSON[args[3]]
  print(str(target))
  </code></pre>
  
  <p>but receive a keyerror exception.</p>
  
  <p>Thanks in advance.</p>