Portable Class Library Build
Json.NET now has a Portable Class Library build that can be found in the /Bin/Portable directory from the zip download on CodePlex. The portable build targets the absolute basics (.NET 4.0, SL4, WP7, Metro) and so hopefully should run on just about everything.
Improved Collection Serialization
JsonArrayAttribute and JsonDictionaryAttribute now have properties to customize the serialization of collection items. ItemConverter, ItemTypeNameHandling, ItemReferenceLoopHandling and ItemIsReference will apply to all the items of that list/dictionary when serializing and deserializing.
- New feature – Added Portable Class Library build
- New feature - Added support for customizing the JsonConverter, type name handling and reference handling of collection items
- New feature - Added Path to JsonReaderException/JsonSerializationException messages
- New feature - Added DateParseHandling to JsonReader
- New feature - Added JsonContainerContract
- New feature - Added JsonDictionaryAttribute
- Change – Instances of Exception have been changed to be a more specific exception
- Fix – Fixed Windows Application Certification tool error by removing AllowPartiallyTrustedCallersAttribute
- Fix - Fixed JsonWriters not using DateTimeZoneHandling
Json.NET 4.5 Release 4 Download – Json.NET source code, documentation and binaries
Json.NET now detects types that have the SerializableAttribute and serializes all the fields on that type, both public and private, and ignores the properties. This is useful when you’re interested in round-tripping the data on a type and don’t care what the JSON looks like.
If you are serializing types that have the attribute and don’t want the new behaviour, it can either be overridden on a type using the JsonObjectAttribute or disabled globally by setting IgnoreSerializableAttribute on DefaultContractResolver to true.
Update: IgnoreSerializableAttribute is true by default in release 3. If you want it you can still achieve this effect by either setting IgnoreSerializableAttribute to false or adding [JsonObject(MemberSerialization.Fields)] to your class.
- New feature - Added support for the SerializableAttribute and serializing a type's internal fields
- New feature - Added MaxDepth to JsonReader/JsonSerializer/JsonSerializerSettings
- New feature - Added support for ignoring properties with the NonSerializableAttribute
- Fix - Fixed deserializing a null string throwing a NullReferenceException
- Fix - Fixed JsonTextReader incorrectly reading from a slow stream
- Fix - Fixed CultureInfo not being overridden on JsonSerializerProxy
- Fix - Fixed full trust security check in .NET 2.0 & .NET 3.5
- Fix - Fixed XmlNodeConverter not turning all attribute properties into attributes
- Fix - Fixed comparing JObjects to ignore property order
- Fix - Fixed reading invalid Unicode surrogate pairs
Json.NET 4.5 Release 2 Download – Json.NET source code, documentation and binaries
In the Json.NET 4.5 release post I added a note about strong naming and assembly version numbers that is worth expanding on.
The problem is a combination of factors: Json.NET is strong named, has frequent releases, the assembly version number changes with each release and many different libraries reference Json.NET.
NuGet does its best to solve the issue of different assemblies referencing different versions by automatically inserting binding redirects for you, but having to rely on a tool to fix up problems is sub-optimal.
The solution that I’m evaluating to improve the situation is to only update the assembly version number on major releases (update: now evaluating never updating the assembly version). For example Json.NET 4.5 R1 has an assembly version number of 184.108.40.206, R2 will have an the version number 220.127.116.11, R3 = 18.104.22.168, and so on. While the assembly version number will be static the assembly file version number will continue to be updated each release so you can identify exactly which version you are using, e.g. 22.214.171.12420.
The .NET framework is doing something similar with .NET 4.5, replacing 4.0 assemblies with new files using the same version number.