How do i make formatted json in C#.NET

Posted by acidzombie24 on Stack Overflow See other posts from Stack Overflow or by acidzombie24
Published on 2010-04-18T03:54:20Z Indexed on 2010/04/18 4:03 UTC
Read the original article Hit count: 265

Filed under:
|
|

I am using .NET json parser and i would like to serialize my config file so it is readable instead of

{"blah":"v", "blah2":"v2"}

to something nicer like

{
    "blah":"v", 
    "blah2":"v2"
}

my code is something like

                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();
                }

© Stack Overflow or respective owner

Related posts about JSON

Related posts about c#