Jan 2 2010

.NET Serialization Performance Comparison

Read more about optimizing Json.NET performance here: Json.NET performance

---

A lot of work around performance went into the latest release of Json.NET, with big improvements in both serializing and deserializing over the previous version.

I can happily say that Json.NET is now faster than both the JavaScriptSerializer and the WCF DataContractJsonSerializer over all scenarios.

Other .NET Serializers

The latest performance improvements now puts Json.NET on the same level as the XML based DataContractSerializer which is pretty remarkable.

Also worth noting is Json.NET over binary (BSON) is considerably faster than the .NET BinaryFormatter.

Serialization Result Data Size

Finally one of the benefits of JSON is its smaller size when compared to equivalent XML. The output of Json.NET is less than half the size of the XML that DataContractSerializer produces (strings have been encoded to UTF8 bytes).

In this test the BSON result is marginally smaller than the JSON result. BSON really shines when serializing byte data (i.e. images, movies, files, etc) where its output will come in at least 30% smaller over JSON because there is no base64 encoding of byte data.

You can find the latest version of Json.NET, including source code with the performance tests, here.