-
The 6.0.0 NuGet version of System.Text.Json is now the minimum supported version.
-
BREAKING CHANGE
JsonTimeSpanConverterandJsonVersionConverterhave been removed.TimeSpanandVersionsupport is now native to System.Text.Json. -
JsonStringEnumMemberConverternow supportsEnums used as dictionary keys. (#27) -
JsonMicrosoftDateTimeConverter&JsonMicrosoftDateTimeOffsetConverterperformance improvements. -
BREAKING CHANGE
JsonMicrosoftDateTimeConverterwill now serializeDateTimeKind.LocalorDateTimeKind.UnspecifiedDateTimes with a time zone offset where previously they would be converted to UTC. Json values including a time zone offset will now be deserialized intoDateTimeKind.Localinstances where previously aJsonExceptionwould be thrown. This is to be compliant with the DateTime Wire Format. (#28)
-
Utf8JsonStreamReadernow supports sequencing when the JSON being read doesn't fit into the default buffer. -
Bumped the
System.Text.Jsonreference to 4.7.2 to resolve a security issue. (#24)
-
Added
PushStreamContent<T>to allow passing of state to the callback invoked to write data to the request stream which can be used to avoid allocation of a delegate. -
If you are using the 5.0.0+ version of System.Text.Json you can now decorate enum values with
JsonPropertyNameinstead ofEnumMemberforJsonStringEnumMemberConverter. (#17) -
Added the
deserializationFailureFallbackValueoption onJsonStringEnumMemberConverter. See the project README for details on its usage. -
Added a constructor on
JsonStringEnumMemberConverterwhich acceptsJsonStringEnumMemberConverterOptions options¶ms Type[] targetEnumTypesparameters for specifying the options to be used to serialize/deserialize the specific target enum types. -
Added
JsonStringEnumMemberConverterOptionsAttributewhich can be used to decorate an enum type with the options to use when serializing/deserializing its values. -
Added
JsonTypeConverterAdapterfor usingTypeConverters with System.Text.Json. (#19) -
Added
Utf8JsonStreamReaderand improved performance ofJsonIPAddressConverter,JsonIPEndPointConverter, &JsonTimeSpanConverteron .NET Standard 2.1+. -
Added
JsonVersionConverter.
-
JsonMicrosoftDateTimeConverter&JsonMicrosoftDateTimeOffsetConverternow write in the format\/Date(...)\/to match the old Microsoft format more closely. -
Improved the performance of
JsonStringEnumMemberConverterbe removing some unnecessary allocations. Added caching of up to 64 value combinations when using[Flags]. -
JsonContenthas been removed because an official version was released with .NET 5. Add the System.Net.Http.Json NuGet to your project to get started (it has targets for .NET Standard, .NET Core, & .NET Framework).Old API (Macross
JsonContent):public async Task SendRequestToService(HttpClient client, Uri requestUri, RequestObject request) { using JsonContent<RequestObject> jsonContent = new JsonContent<RequestObject>(request); using HttpResponseMessage response = await client.PostAsync(requestUri, jsonContent).ConfigureAwait(false); response.EnsureSuccessStatusCode(); }
New API (.NET 5
JsonContent):Project:
<PackageReference Include="System.Net.Http.Json" Version="5.0.0" Condition="'$(TargetFramework)' != 'net5.0'" />
Code:
using System.Net.Http.Json; public async Task SendRequestToService(HttpClient client, Uri requestUri, RequestObject request) { using JsonContent jsonContent = JsonContent.Create(request); using HttpResponseMessage response = await client.PostAsync(requestUri, jsonContent).ConfigureAwait(false); response.EnsureSuccessStatusCode(); }
-
Exceptions thrown during deserialization now include JSON path information as part of the exception message.