Json Serialization

I’ve been having fun trying to implement an idea I have. Part of the idea involves caching objects to memcached in Json format. The idea being that the object saved to memcached wouldn’t be bound to .Net specific methodology.

What’s out There

At first I looked into creating a Custom Formatter that would serialize my object for me. That seemed like an overkill so I searched for a faster and prepackaged library. After poking around to see what Json serializers were on the market, I found Json.NET.

At first this looked like a possible solution. Then I ran the Test Scripts on the Project and found a PerformanceTests test. This test script had timings for three different types of serializers. So my options were:


I changed the Json.Net Performance tests to serialize and deserialize 1000 times. The JavaScriptSerializer was the fastest during the tests.

JsonNet203 ms
JavaScriptSerializer95 ms
DataContractJsonSerializer842 ms


One of the bad things I saw happen is how the DataContractJsonSerializer tried to serialize the private methods of the class. So I though I would try to force it to use the properties of the class by not defining a backing variable.

public string Name { get; set; }

What to my surprise when I saw the following in the Json output: