title: How to create multidimensional json object in a loop?
body: <p>I am using the following code to search through a folder structure and write all package names and versions into a string.</p>
  <pre class="lang-py prettyprint-override"><code>#!/usr/bin/python3
  
  import glob
  import json
  
  repo_list = [&quot;core&quot;, &quot;multilib&quot;, &quot;nonfree&quot;, &quot;testing&quot;] 
  
  for i in repo_list:
      print(i)
      for name in glob.glob('../' + i +'/*/spkgbuild'): 
          package_name = ''
          package_version = ''
          temp_json = ''
          package = open(name,'r')
          Lines = package.readlines()
          for line in Lines:
              if(line.strip().startswith('name')):
                  package_name = line.strip()[5:]
              if(line.strip().startswith('version')):
                  package_version = line.strip()[8:]
              if(package_name != '' and package_version != ''):
                  temp_json = {package_name: {&quot;version&quot;: package_version}}
  </code></pre>
  <p>From this I actually want to have the following JSON object later:</p>
  <pre class="lang-json prettyprint-override"><code>{
    &quot;core&quot;: {
      &quot;package_name&quot;: {
        &quot;version&quot;: &quot;1.1.1&quot;
      },
      &quot;package_name2&quot;: {
        &quot;version&quot;: &quot;1.1.1&quot;
      }
    }
  }
  </code></pre>
  <p>I'm stuck writing the object now, can you help me there?</p>