I need an easy-to-setup JSON library for C# .NET that can work well with strongly-typed Lists and Dictionaries. I’ve been working with fastJSON, which is lightweight and portable. However the methods ToJSON and ToObject do not always work with strongly typed objects such as List<string>. I need a simple library that can execute the following correctly:
// parse a JSON file
List<string> names = JSON.parse<List<string>>(json1);
Dictionary<string, int> ids = JSON.parse<Dictionary<string, int>>(json);
// stringify an object
string json = JSON.stringify(names);
string json = JSON.stringify(ids);
Obviously the ideal library should be fast (fast enough to scale to JSONs that are hundreds of MBs), and portable (small code, no dependencies), but no fusses. I’m pretty desperate right now so anything that works is fine.
http://james.newtonking.com/projects/json-net.aspx is the usual answer but there are many more.