Json.NET 6.0 Release 6 Adds ASP.NET CoreCLR Support and Memory Optimizations

Json.NET 6.0 Release 6 has been released by James Newton-King with support for ASP.NET CoreLCR support. The release also adds several improvements related to memory usage in addition to several bug fixes.

Json.NET 6.0 Release 6 has been released with support for ASP.NET CoreCLR, an upcoming server optimized CLR for running applications in the cloud. The latest release of Json.NET optimizes memory usage, that enable heap allocations when reading and writing JSON.

If you are unaware, Json.NET has always been memory efficient by streaming the reading and writing large documents rather than loading them entirely into memory.

“Deserialization saw the biggest improvement with about a 35% decrease in allocations,” said James, Lead Developer, Json.NET based in New Zealand.

James posted a screenshot which shows the before memory timeline when deserializing a 5 meg JSON file

Json.NET 6.0 Release 6

He also posted a capture after the end of timeline

Json.NET 6.0 Release 6 After Timeline

Legend for the above captures

Unmanaged memory – Grey
Gen0 heap – Blue
Gen1 – Red
Gen2 – Green

In addition to the above mentioned ASP.NET CoreCLR support, Json.NET 6 also added support for passing arguments to JsonConverters with JsonConvertAttribute and JsonConvert.ToString overload that takes a StringEscapeHandling parameter. Moreover, the new release also reduced memory allocations when reading and writing JSON.

Json.NET 6 includes few changes as mentioned below

  • Omit fields array for F# discriminated union serialization when there are no fields
  • Escape property names in path on readers/writers/tokens when a name contains special characters
  • Provide line numbers for end tokens on JTokenReader

Json.NET 6 has fixed parsing in SelectToken, error when deserializing a GUID from certain BSON, null reference error when using aJEnumerable and line breaks in exception messages to make use of Environment.NewLine. The latest release also provides fix for MetadataTypeAttribute and immutable collections reflection errors on ASP.NET CoreCLR.



Leave a Comment