title: Correctly create a json file in c#
body: <p>I'm currently setting-up my application, and i need to manage a json file (that contain some settings) in my windows form. Once you open it, you can easy choose different settings, and once you've done, you can save it (which mean i need to overwrite the existing one json file settings, and replace it with new one!</p>
  <hr />
  <p>I tried to follow <a href="https://stackoverflow.com/questions/16921652/how-to-write-a-json-file-in-c">this</a> guide for correctly create my json file! But i met 2 problems:</p>
  <ol>
  <li>This solution mentioned up, create square brackets (which i don't need!)</li>
  <li>Seems to create all settings on one line. Is that correct or it could make some problem in the future?</li>
  </ol>
  <hr />
  <p>Some materials....</p>
  <p>My application:</p>
  <p><a href="https://i.stack.imgur.com/R97iC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/R97iC.png" alt="" /></a></p>
  <p>Original json file:</p>
  <p><a href="https://i.stack.imgur.com/hvfAI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hvfAI.png" alt="" /></a></p>
  <p>Json file generated with my code:</p>
  <p><a href="https://i.stack.imgur.com/5CjiL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5CjiL.png" alt="" /></a></p>
  <p>My class:</p>
  <pre><code>    public class data
      {
          public bool avx { get; set; }
          public bool memory_pool { get; set; }
          public bool smt { get; set; }
          public bool spectre { get; set; }
          public bool unlock_menu { get; set; }
          public bool vinput { get; set; }
          public double cpu_memory_pool_fraction { get; set; }
          public double gpu_memory_pool_fraction { get; set; }
      }
  </code></pre>
  <p>My code:</p>
  <pre><code>private void btn_save_Click(object sender, EventArgs e)
  {
      string settings_path = general_path + &quot;\\plugins\\cyber_engine_tweaks\\&quot; + &quot;config.json&quot;; //path
  
      bool avx_set = cb_avx.Checked;
      bool smt_set = cb_smt.Checked;
      bool memory_set = cb_memory.Checked;
      bool spectre_set = cb_spectre.Checked;
      bool debug_set = cb_debug.Checked;
      bool vinput_set = cb_vinput.Checked;
  
      List&lt;data&gt; _data = new List&lt;data&gt;();
      _data.Add(new data()
      {
          avx = avx_set,
          cpu_memory_pool_fraction = 0.5,
          gpu_memory_pool_fraction = 1.0,
          memory_pool = memory_set,
          smt = smt_set,
          spectre = spectre_set,
          unlock_menu = debug_set,
          vinput = vinput_set
      });
  
      using (StreamWriter file = File.CreateText(settings_path))
      {
          JsonSerializer serializer = new JsonSerializer();
          //serialize object directly into file stream
          serializer.Serialize(file, _data);
      }
  }
  </code></pre>