JsonRazor 1.5.1

Extreme performance JSON management library. Simple & as fast as possible. New features, bug fixes and performance improvements.

Install-Package JsonRazor -Version 1.5.1
dotnet add package JsonRazor --version 1.5.1
<PackageReference Include="JsonRazor" Version="1.5.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add JsonRazor --version 1.5.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: JsonRazor, 1.5.1"
For F# scripts that support #r syntax, copy this into the source code to reference the package.
// Install JsonRazor as a Cake Addin
#addin nuget:?package=JsonRazor&version=1.5.1

// Install JsonRazor as a Cake Tool
#tool nuget:?package=JsonRazor&version=1.5.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

1.5.1:

Changes to existing code:

  • Deserialization of not supported collection type (not T[] or List<T>) will now throw InvalidOperationException instead of returning null.
  • JsonArray's tokens are no longer grouped by type, as they are now in source order. First... properties continue to work.

Fixes:

  • JsonValue.Equals() wouldn't perform actual comparisons.
  • JsonComposite.FirstObject or FirstArray properties would sometimes return null when not parsed, regardless of token existance.
  • IToken.LoadTokens() would probably return tokens in reversed order on subsequent calls. Now array will always return source order. Order for object remains unchanged, but it may be subject to change; indexer is recommended way of accesing child tokens. Nevertheless, LoadTokens() will always return correct order on first enumeration, regardless of token type.
  • Very rare exception thrown during IToken parsing with long values.
  • Very rare error that would sometimes result in broken parsed data or exception when values contained \ escape sequences.
  • CodeGenDeserializer.ToType() could probably throw AccessException under .NET Framework.
  • JsonReader implements IDisposable.
  • Few documentation comments, that were obviously stating wrong, ie. Deserializer.UseInfo.

New features:

  • Added JsonValue.Equals(JsonValue).
  • Added JsonReader.Open(StreamReader) method. Its purpose is to make sure that internal structures will be released when parsing from stream finishes. It is recommended to call it inside using() block instead of creating new JsonReader, as it will not cause unnecessary allocations.
  • Added JsonArray.TokenAt(int) method, that returns token at given index. The index, at which token is returned, is equal to that of JsonToken.Index property.
  • CachingDeserializer.UseInternalParsing flag, that enables usage of experimental parsing algorithm. It can provide to 25% shorter execution time and probably no more than 30% reduction in memory usage (depends heavily on structure, data size etc.). It can't be used when model has any property/field or any collection of type object, that is to be populated with raw tokens. False by default. Has no effect on IToken deserialization with given instance.
  • CodeGenDeserializer instance can now be shared across multiple threads when deserializing from string to given type. Only requirement is that it must have performed deserialization for given type at least once before being shared.

Performance:

  • CodeGenDeserializer performance for subsequent deserializations has improved up to 30-40%. Also number of allocations should be lower. The tradeoff is that first deserialization for given type might be somewhat slower.
  • Deserialization to model containing nullable types has been improved up to 15%.
  • Multiple collection deserializations has been improved (lost actual measurements, around 10-15%). Also number of allocations is reduced.
  • List<T> deserialization has been improved for IToken around 5-10%.
  • Reduced allocation size of TokensWithNulls() enumerator.
  • Reduced allocation size of JsonObject and JsonArray. JsonObject deserialization allocations were also reduced.

While these changes look nice to me, I'm really looking forward to begin to work on final piece, a dedicated serialization engine for ASP.NET Core, that works on UTF8, removing the need for char - byte conversions.
I'll try to aim for fastest serialization & deserialization out there.

1.5.1:

Changes to existing code:

  • Deserialization of not supported collection type (not T[] or List<T>) will now throw InvalidOperationException instead of returning null.
  • JsonArray's tokens are no longer grouped by type, as they are now in source order. First... properties continue to work.

Fixes:

  • JsonValue.Equals() wouldn't perform actual comparisons.
  • JsonComposite.FirstObject or FirstArray properties would sometimes return null when not parsed, regardless of token existance.
  • IToken.LoadTokens() would probably return tokens in reversed order on subsequent calls. Now array will always return source order. Order for object remains unchanged, but it may be subject to change; indexer is recommended way of accesing child tokens. Nevertheless, LoadTokens() will always return correct order on first enumeration, regardless of token type.
  • Very rare exception thrown during IToken parsing with long values.
  • Very rare error that would sometimes result in broken parsed data or exception when values contained \ escape sequences.
  • CodeGenDeserializer.ToType() could probably throw AccessException under .NET Framework.
  • JsonReader implements IDisposable.
  • Few documentation comments, that were obviously stating wrong, ie. Deserializer.UseInfo.

New features:

  • Added JsonValue.Equals(JsonValue).
  • Added JsonReader.Open(StreamReader) method. Its purpose is to make sure that internal structures will be released when parsing from stream finishes. It is recommended to call it inside using() block instead of creating new JsonReader, as it will not cause unnecessary allocations.
  • Added JsonArray.TokenAt(int) method, that returns token at given index. The index, at which token is returned, is equal to that of JsonToken.Index property.
  • CachingDeserializer.UseInternalParsing flag, that enables usage of experimental parsing algorithm. It can provide to 25% shorter execution time and probably no more than 30% reduction in memory usage (depends heavily on structure, data size etc.). It can't be used when model has any property/field or any collection of type object, that is to be populated with raw tokens. False by default. Has no effect on IToken deserialization with given instance.
  • CodeGenDeserializer instance can now be shared across multiple threads when deserializing from string to given type. Only requirement is that it must have performed deserialization for given type at least once before being shared.

Performance:

  • CodeGenDeserializer performance for subsequent deserializations has improved up to 30-40%. Also number of allocations should be lower. The tradeoff is that first deserialization for given type might be somewhat slower.
  • Deserialization to model containing nullable types has been improved up to 15%.
  • Multiple collection deserializations has been improved (lost actual measurements, around 10-15%). Also number of allocations is reduced.
  • List<T> deserialization has been improved for IToken around 5-10%.
  • Reduced allocation size of TokensWithNulls() enumerator.
  • Reduced allocation size of JsonObject and JsonArray. JsonObject deserialization allocations were also reduced.

While these changes look nice to me, I'm really looking forward to begin to work on final piece, a dedicated serialization engine for ASP.NET Core, that works on UTF8, removing the need for char - byte conversions.
I'll try to aim for fastest serialization & deserialization out there.

Release Notes

New features, bug fixes and performance improvements. Check changelog on nuget.org for details.

  • .NETCoreApp 2.0

    • No dependencies.
  • .NETCoreApp 2.1

    • No dependencies.
  • .NETFramework 3.5

    • No dependencies.
  • .NETFramework 4.5

    • No dependencies.
  • .NETStandard 2.0

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.5.1 849 9/27/2019
1.5.0 306 7/27/2019
1.4.0 316 6/5/2019
1.3.1 447 1/25/2019
1.3.0 404 1/1/2019
1.2.2.8 670 7/6/2018
1.2.2.7 586 6/25/2018
1.2.2.6 541 6/9/2018
1.2.2.5 796 3/31/2018
1.2.2.2 628 10/7/2017
1.2.2.1 590 10/4/2017
1.2.2 606 10/1/2017
1.2.0.1 583 8/15/2017
1.1.0.10 698 6/25/2017