Why isn't JSON.NET compatible with the JSON standard?

May 6, 2012 at 4:04 AM
Edited May 6, 2012 at 4:05 AM

According to this issue, JSON.NET does not adhere to the JSON standard => An object is an unordered set of name/value pairs. An object begins with { (left brace) and ends with } (right brace). Each name is followed by : (colon) and the name/value pairs are separated by , (comma).

JSON objects that do not put $type at the beginning of the object will not deserialize into JSON.NET and in fact throw an exception. I can understand for performance reasons why that assumption would be made but it seems as if you would want to offer a switch that would offer a graceful way of handling it (a bool that is AssumeTypeFirst) which is off by default? I know the $type feature was added relatively recently so if users start attempting to use these JSON.NET specific features with one of the other 100+ JSON libraries that exist it won't always work.

May 7, 2012 at 12:55 PM

This isn't going to change. If you want to use $type you have to put it first.