title: how to parse json where key is variable in python?
body: <p>i am parsing a log file which is in json format,
  and contains data in the form of key : value pair.</p>
  <p>i was stuck at place where key itself is variable. please look at the attached code</p>
  <p>in this code i am able to access keys like username,event_type,ip etc.</p>
  <p>problem for me is to access the values inside the &quot;submission&quot; key  where</p>
  <p><strong>i4x-IITB-CS101-problem-33e4aac93dc84f368c93b1d08fa984fc_2_1</strong>    is a variable key which will change for different users,</p>
  <p>how can i access it as a variable ?</p>
  <pre><code>{
      &quot;username&quot;: &quot;batista&quot;,        
      &quot;event_type&quot;: &quot;problem_check&quot;,      
      &quot;ip&quot;: &quot;127.0.0.1&quot;,
      &quot;event&quot;: {
          &quot;submission&quot;: {
              &quot;i4x-IITB-CS101-problem-33e4aac93dc84f368c93b1d08fa984fc_2_1&quot;: {
                  &quot;input_type&quot;: &quot;choicegroup&quot;,
                  &quot;question&quot;: &quot;&quot;,
                  &quot;response_type&quot;: &quot;multiplechoiceresponse&quot;,
                  &quot;answer&quot;: &quot;MenuInflater.inflate()&quot;,
                  &quot;variant&quot;: &quot;&quot;,
                  &quot;correct&quot;: true
              }
          },
          &quot;success&quot;: &quot;correct&quot;,
          &quot;grade&quot;: 1,
          &quot;correct_map&quot;: {
              &quot;i4x-IITB-CS101-problem-33e4aac93dc84f368c93b1d08fa984fc_2_1&quot;: {
                  &quot;hint&quot;: &quot;&quot;,
                  &quot;hintmode&quot;: null,
                  &quot;correctness&quot;: &quot;correct&quot;,
                  &quot;npoints&quot;: null,
                  &quot;msg&quot;: &quot;&quot;,
                  &quot;queuestate&quot;: null
              }
          }
  </code></pre>
  <p>this is my code how i am solving it :</p>
  <pre><code>import json
  import pprint
  with open(&quot;log.log&quot;) as infile:
  # Loop until we have parsed all the lines.
  for line in infile:
      # Read lines until we find a complete object
      while (True):
          try:
              json_data = json.loads(line)
  
              username = json_data['username']
              print &quot;username :- &quot; + username
  
          except ValueError:                
              line += next(infile)
  </code></pre>
  <p>how can i access <strong>i4x-IITB-CS101-problem-33e4aac93dc84f368c93b1d08fa984fc_2_1</strong>  key and</p>
  <p>data inside this key ??</p>