JSON Toolkit 4.0Posted on 6/19/2012
JSON Toolkit 4.0 further improves the performance of JSON Toolkit and supports more platforms like Windows Phone and Windows 8.
- Up to 2.5x performance improvement in stringify operations
- Up to 1.7x performance improvement in parse operations
- Improved error messages when parsing invalid JSON strings
- Extended support to .Net 2.0, .Net 3.5, .Net 4.0, Silverlight 4, Windows Phone, Windows 8 metro apps and Xbox
- Available at NuGet
- JSON namespace changed to ComputerBeacon.Json namespace
The new library is not compatible to Facebook Graph Toolkit yet, because it involves a namespace change. It will be integrated with FGT 4.0, which will bring support to ASP.NET MVC, Silverlight, Windows Phone, Windows 8, Open Graph, Facebook Page Administration and more.
It's very fast
To give you an idea how fast JSON Toolkit 4.0 is, the graphs below show the time taken to parse different JSON data. The sample data used in the test are:
OP Feed: The posts on the Facebook Page of Ocean Park Hong Kong,
CB Feed: The posts on the Facebook Page of Computer Beacon, obtained at https://graph.facebook.com/computerbeacon/posts
Java Servlet: data of Servlets
Bing: A sample response from the Bing Api
All graphs measure the time taken to repeat the operation 5000 times. Smaller values are better.
Improvement in 4.0
The graph below illustrates the difference in parsing performance of Version 4.0 against Version 3.1.
JSON Toolkit is one of the fastest .NET libraries for managing JSON strings and objects. To illustrate this, three different libraries are brought together for comparison:
The tests are conducted by parsing a JSON string into a JSON object instance or Dictionary<string,object> instance. The time is measured by repeating the tests 5000 times. Here are the results:
Time to parse a sample JSON string 5000 times. Smaller values are better.
As we can see, JSON Toolkit takes much less time to parse JSON objects, particularly those from Facebook. When an application using Facebook Graph Toolkit is deployed to the server, JSON Toolkit will save your server resources!
JSON Toolkit also offers the ability to "stringify" a JsonObject or JsonArray, i.e. given an instance in memory, turn that object into a string which can be stored or transmitted and then converted back to JsonObject or JsonArray instance later.
The chart below compares the performance of different libraries in performing the equipvalent of "stringify" operation:
Time to strinfigy JSON objects 5000 times. Smaller values are better.
The above tests are conducted under the following environment:
Hardware: Intel E8400, 8GB DDR2-1066 RAM
Software: Windows 7 x64 SP1
Test project: .NET 4.0, x86 Release build
Support for more platforms
JSON Toolkit is now compiled to a portable class library. This dll can be used in Silverlight, Windows Phone, XNA games and also Windows 8. As a side note, it is used in one of my recent Windows Phone applications to persist data between app launches :->
You may notice that the deserialize<T> method has been removed in this release. The reason is that JSON Toolkit was originally designed to support Facebook Graph Toolkit only by handling parse operations. During development of version 4.0 it was decided that the whole serialize and deserialize algorithms have to be rewritten to achieve maximum performance. To avoid delaying FGT, the deserialize method is temporarily removed and will be added back later.
|Next: Debug Facebook Applications in Visual Studio using SSL||Previous: FGT Update v3.1|