tags:

views:

90

answers:

3

I've been looking into several JSON parsers for .NET (LitJSON, JsonExSerializer and JSON.NET), and was wondering if anyone has any experience with them and can shed some light on the differences and the pros and cons for each of them.

+2  A: 

Don't forget, .NET 3.5 introduced the JavaScriptSerializer class which does JSON as well. I haven't used the others because I've always just used the built-in one: it works well enough for everything I've needed.

Dean Harding
+1. The internal one is fast and lightweight and I haven't had any issues with it. Only if you have specific problems I would recommend looking at the others.
ntziolis
Unfortunately, I'm tied to .NET 2.0...
On Freund
JavaScriptSerializer has some major shortcomings, especially when dealing with JSON coming back from an Ajax or WCF service. But it can be augmented to behave as well as JSON.Net see http://www.codeproject.com/KB/aspnet/Parsing-ClientScript-JSON.aspx
Sky Sanders
I wouldn't call this "major shortcomings" of the JavaScriptSerializer! In fact it's not even shortcomings of this class! It's a problem that has nothing to do with the serializer, and everything with your approach there =/The serializer does exactly what it has to do - serializes and deserializes a Json object to a .NET object...
Artiom Chilaru
A: 

Since this thread seems to attract very little attention, here's what I ended up doing: liJson was out of the picture pretty fast as it does not seem to be actively maintained. Between the remaining two (both released versions just a few days ago) I chose Json.NET as it seems to

  1. have a slightly simpler serialization API.
  2. be more popular.

After a few experiments I have to say I'm happy with the results - I managed to achieve all I wanted and more, and writing custom converters was a breeze, taking 2 minutes and 4 lines of code.

On Freund
+1  A: 

JavaScriptSerializer has some major shortcomings out of the box, but with a bit of cajoling it can be convinced to do some neat stuff, like deserializing d: wrapped msajax json and typed wcf json as well as deserializing to anonymous types.

See http://www.codeproject.com/KB/aspnet/Parsing-ClientScript-JSON.aspx

Sky Sanders