title: Key error in dictionary - different structure
body: <p>I'm getting that classic error on dictionary. I already try all possibilities that I knew but didn't work. It seems the symbol '[' is the cause of the problem. </p>
  
  <p>Basically, what I want to do is change the key name in json. I'm following <a href="https://www.geeksforgeeks.org/python-ways-to-change-keys-in-dictionary/" rel="nofollow noreferrer">this example</a> and it works fine, however, when I try to use my own json, it doesn't work (see the '[' on my json). </p>
  
  <p>How can I workaround it? 
  P.S: I'm getting that json result from an internal system and I cannot change that. </p>
  
  <p>Here is my code and the error I'm getting:</p>
  
  <pre><code>import json
  line = {'result': [{'end_date': '2020-05-15 05:00:00', 'number': 'CG0239308', 'cmdb_ci.u_alias': 'DNS', 'short_description': 'DNS test ', 'start_date': '2020-05-15 02:00:00'}]}
  line2 = json.dumps(line)
  result = json.loads(line2)
  
  print ('line result:', json.dumps(result, indent=5))
  
  ini_dict = result
  
  ###Changing dictionary key
  # printing initial json 
  print ("initial 1st dictionary", ini_dict) 
  
  # changing keys of dictionary 
  ini_dict['New_Name'] = ini_dict['cmdb_ci.u_alias'] 
  del ini_dict['cmdb_ci.u_alias']
  
  # printing final result 
  print ("final dictionary", str(ini_dict)) 
  </code></pre>
  
  <p>Here is the output of the code and the error:</p>
  
  <pre><code>line result: {
       "result": [
            {
                 "end_date": "2020-05-15 05:00:00",
                 "number": "CG0239308",
                 "cmdb_ci.u_alias": "DNS",
                 "short_description": "DNS test ",
                 "start_date": "2020-05-15 02:00:00"
            }
       ]
  }
  Traceback (most recent call last):
    File "C:\Users\renato\Desktop\dict.py", line 20, in &lt;module&gt;
      ini_dict['New_Name'] = ini_dict['cmdb_ci.u_alias']
  KeyError: 'cmdb_ci.u_alias'
  </code></pre>