title: Using json.dumps to load configure file
body: <p>I am trying to edit a configuration file on python and then write the edited configuration to a file. Here is a small snippet of it</p>
  <pre><code>    pars[&quot;ggv_file&quot;] = json.loads(parser.get('GENERAL_OPTIONS', 'ggv_file'))
      pars[&quot;ax_max_machines_file&quot;] = json.loads(parser.get('GENERAL_OPTIONS', 'ax_max_machines_file'))
      pars[&quot;stepsize_opts&quot;] = json.loads(parser.get('GENERAL_OPTIONS', 'stepsize_opts'))
      ...
  </code></pre>
  <p>The first two configuration option only has one value to change, and others have more within them. I just use something like <code>pars[&quot;ggv_file&quot;] = &quot;notggv_file.csv&quot;</code> to change the value. Then I experimented using</p>
  <pre><code>    setPars.add_section('GENERAL_OPTIONS')
      setPars.set('GENERAL_OPTIONS', 'ggv_file', str(pars[&quot;ggv_file&quot;]))
      setPars.set('GENERAL_OPTIONS', 'ax_max_machines_file', str(pars[&quot;ax_max_machines_file&quot;]))
      ...
      setPars.set('OPTIMIZATION_OPTIONS', 'vehicle_params_mintime', str(pars[&quot;vehicle_params_mintime&quot;]))
      ...
      setPars.write(somefile)
  </code></pre>
  <p>Now I want to add this configuration to another file. I tried using dumps to connect everything together, but it seems to have made some more changes to it or something. Because once it has been edited, now it does not recognize the file as it used to. If I run the same program on the file that it just edited, it shows</p>
  <pre><code>raise JSONDecodeError(&quot;Expecting value&quot;, s, err.value) from None
  
  JSONDecodeError: Expecting value
  </code></pre>
  <p>Is there a way I can parse, edit and overwrite configuration file better, or could you find anything wrong with my approach? As per the title, I tried using .dumps to line them up but that did absolutely nothing. This approach here gives me the output, but when the same thing gets run on it, it does not recognize them.</p>
  <p>Here is what I tried for json.dumps, for anyone that want to take a look at that:</p>
  <pre><code>parser = json.dumps([&quot;GENERAL_OPTIONS&quot;, pars[&quot;ggv_file&quot;], pars[&quot;ax_max_machines_file&quot;], pars[&quot;stepsize_opts&quot;],
              pars[&quot;reg_smooth_opts&quot;], pars[&quot;veh_params&quot;], pars[&quot;vel_calc_opts&quot;],&quot;[OPTIMIZATION_OPTIONS]&quot;,
              pars[&quot;optim_opts&quot;], pars[&quot;curv_calc_opts&quot;], pars[&quot;vehicle_params_mintime&quot;],
              pars[&quot;tire_params_mintime&quot;], pars[&quot;pwr_params_mintime&quot;]])
  ...
  pars.write(somefile)
  </code></pre>
  <p>This is the initialization call:</p>
  <pre><code>    parser = configparser.ConfigParser()
      setPars = configparser.ConfigParser()
      pars = {}
  </code></pre>
  <p>to be noted here, the use of setPars is instead of using the .dumps function. Here a new configuration parser is being created as setPars and values being added to it. Finally, that gets written in the file. And where parser was reused to overwrite existing value, instead of adding each configuration individually, it tries to use the .dumps function to put the modified list together, and that gets written out.</p>