.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.

Chalmers: "Seymour, you're fired." Skinner: "Did you just call me a liar?" Chalmers: "No, I said you were fired." Skinner: "Oh, that's much worse." 

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.

Australian man: "You call that a knife? This is a knife!" Bart: "That's not a knife. That's a spoon." Australian man: "All right, all right, you win. Heh. I see you've played knifey-spooney before."

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.

Some men hunt for sport, others hunt for food. The only thing I'm hunting for... is an outfit that looks good. See my vest, see my vest, made from real gorilla chest. See this sweater? There's no better, than authentic Irish Setter. See this hat? 'Twas my cat. My evening wear vampire bat. These white slippers are albino, african endangered rhino. Grizzle-bear underwear, turtle's necks I've got my share. Beret of poodle on my noodle it shall rest. Try my red robin suit. It comes one breast or two. See my vest, see my vest. See my vest!! Like my loafers? Former gophers. It was that or skin my chauffeurs. But a greyhound-fur tuxedo would be best. So, let's prepare these dogs. (Old Woman) Kill two for matching clogs! See my vest... See my vest! Oh please, won't you see my vest!!

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

 

kick it on DotNetKicks.com