title: How do I get formatted JSON in .NET using C#?
body: <p>I am using .NET JSON parser and would like to serialize my config file so it is readable. So instead of:</p>
  <pre class="lang-json prettyprint-override"><code>{&quot;blah&quot;:&quot;v&quot;, &quot;blah2&quot;:&quot;v2&quot;}
  </code></pre>
  <p>I would like something nicer like:</p>
  <pre class="lang-json prettyprint-override"><code>{
      &quot;blah&quot;:&quot;v&quot;, 
      &quot;blah2&quot;:&quot;v2&quot;
  }
  </code></pre>
  <p>My code is something like this:</p>
  <pre class="lang-cs prettyprint-override"><code>using System.Web.Script.Serialization; 
  
  var ser = new JavaScriptSerializer();
  configSz = ser.Serialize(config);
  using (var f = (TextWriter)File.CreateText(configFn))
  {
      f.WriteLine(configSz);
      f.Close();
  }
  </code></pre>