DI/IoC agnostic interfaces for injecting any serialization library.
With the following libraries, you can build other libraries that sever their dependency from any serializer and allow you to inject whichever you want. You can also easily integrate another serializer and still retain the DI/IoC happiness.
https://www.nuget.org/packages/Open.Serialization Core package for serializing anything.
https://www.nuget.org/packages/Open.Serialization.Json Core package specific to JSON.
services.AddJsonSerializer();The following libs contain support for Microsoft.Extensions.DependencyInjection.
Import any of these and you can use the above extension to inject default serializers.
https://www.nuget.org/packages/Open.Serialization.Json.Newtonsoft Extensions and DI for Newtonsoft.Json.
https://www.nuget.org/packages/Open.Serialization.Json.System Extensions and DI for System.Text.Json. Note: There is no
IJsonObjectSerializer option for System.Text.Json.
https://www.nuget.org/packages/Open.Serialization.Json.Utf8Json Extensions and DI for Utf8Json.
TIDeserialize.Deserialize<T>(stringvalue);TIDeserialize<T>.Deserialize(stringvalue);objectIDeserializeObject.Deserialize(stringvalue,Typetype);ValueTask<T>IDeserializeAsync.DeserializeAsync<T>(Streamsource,CancellationTokencancellationToken=default);
ValueTask<T>IDeserializeAsync<T>.DeserializeAsync(Streamsource,CancellationTokencancellationToken=default);
ValueTask<object>IDeserializeObjectAsync.DeserializeAsync(Streamsource,Typetype,CancellationTokencancellationToken=default);string ISerialize.Serialize<T>(Titem);stringISerialize<T>.Serialize(Titem);stringISerializeObject.Serialize(objectitem,Typetype);ValueTaskISerializeAsync.SerializeAsync<T>(Streamtarget,Titem,CancellationTokencancellationToken=default);ValueTaskISerializeAsync<T>.SerializeAsync(Streamtarget,Titem,CancellationTokencancellationToken=default);ValueTaskISerializeObjectAsync.SerializeAsync(Streamtarget,objectitem,Typetype,CancellationTokencancellationToken=default);