JSON Serializers

Disclaimer

These tests might be very inaccurate.

Please do not rely on these and do point any mistakes or inconsistencies.

General information

Name DataContractJsonSerializer fastJSON JavaScriptSerializer Jil NETJson Newtonsoft.Json ServiceStack JSON
Version 4.0.0.0 2.1.15.0 4.0.0.0 2.14.3 1.1.0.1 8.0.3 4.0.56
Released n/a mar 2016 n/a may 2016 apr 2016 mar 2016 apr 2016
Distribution built-in binary built-in binary binary binary binary
Web Site n/a link n/a link link link link
License n/a n/a n/a MIT 404 MIT unrecognized
Downloads n/a 72 176 n/a 144 510 13 909 48 064 592 2 015 992
Total Score 48% 20% 60% 56% 44% 88% 56%

Supported .NET versions

This information is based on versions included in NuGet package.

Name DataContractJsonSerializer fastJSON JavaScriptSerializer Jil NETJson Newtonsoft.Json ServiceStack JSON
.NET 2.0 n/a yes n/a no no yes no
.NET 3.5 n/a yes n/a no yes yes no
.NET 4.0 n/a yes n/a no yes yes yes
.NET 4.5 n/a yes n/a yes yes yes yes
Windows 8 n/a no n/a no no yes yes
Windows Universal (8.1) n/a no n/a no no yes no
Windows Phone 8.0 n/a no n/a no no yes no
Silverlight 5 n/a no n/a no no yes yes
dnxcore 5.0 n/a no n/a no no yes no
MonoAndroid n/a no n/a no no no yes
MonoTouch n/a no n/a no no no yes
Xamarin iOS 1.0 n/a no n/a no no yes yes

Simple types

Tests on simple types -- top level primitive.

Name DataContractJsonSerializer fastJSON JavaScriptSerializer Jil NETJson Newtonsoft.Json ServiceStack JSON
string pass pass pass pass pass pass pass
int pass pass pass pass pass pass pass
DateTime fail fail fail pass pass pass fail
DateTimeOffset fail fail pass pass fail pass pass
Uri pass fail pass fail fail pass pass

Collections

Name DataContractJsonSerializer fastJSON JavaScriptSerializer Jil NETJson Newtonsoft.Json ServiceStack JSON
string[] pass fail pass pass pass pass pass
object[] pass fail pass fail pass fail fail
List pass pass pass pass pass pass pass
IList pass fail pass pass fail pass pass
HashSet pass fail fail pass pass pass pass
ISet fail fail fail pass fail pass fail
IReadOnlyList fail fail pass pass fail pass pass
IReadOnlyCollection fail fail pass fail fail pass pass
IEnumerable pass fail pass pass fail pass pass

Dictionaries

Sometimes it is inconvenient or impossible to define schema as a static type in advance. This leaves two options -- dictionaries and dynamic types. These tests look at dictionary support.

Name DataContractJsonSerializer fastJSON JavaScriptSerializer Jil NETJson Newtonsoft.Json ServiceStack JSON
Basic fail fail pass fail pass pass pass
Nested fail fail pass fail pass fail fail

Read-only properties

It is often a good idea to avoid public setters for certain properties. One classic example is collection properties, which are often recommended to be readonly to ensure the collection is always non-null.

Since there are other ways to set those properties (e.g. Add for collections), there should be no need for bad design just to satisfy the serializer.

Name DataContractJsonSerializer fastJSON JavaScriptSerializer Jil NETJson Newtonsoft.Json ServiceStack JSON
ICollection<T> property fail fail fail fail fail pass fail
ISet<T> property fail fail fail fail fail pass fail
Mutable class property fail fail fail fail fail pass fail

Constructors

Name DataContractJsonSerializer fastJSON JavaScriptSerializer Jil NETJson Newtonsoft.Json ServiceStack JSON
Custom constructor: deserialized pass fail fail fail fail pass pass
Custom constructor: actually called fail fail fail fail fail pass fail

Dynamic

Sometimes it is inconvenient or impossible to define schema as a static type in advance. This leaves two options -- dictionaries and dynamic types. These tests look at dynamic support.

Name DataContractJsonSerializer fastJSON JavaScriptSerializer Jil NETJson Newtonsoft.Json ServiceStack JSON
dynamic => int pass pass pass pass pass pass fail
dynamic => string pass pass pass pass pass pass pass
dynamic property access fail fail fail pass fail pass fail
dynamic cast to type fail fail fail fail fail fail fail

Not tested

List of libraries I couldn't test, with corresponding reasons.

Jv.Json
Seems to be dynamic-only.