ImanSoftware.Serialization
1.0.2
dotnet add package ImanSoftware.Serialization --version 1.0.2
NuGet\Install-Package ImanSoftware.Serialization -Version 1.0.2
<PackageReference Include="ImanSoftware.Serialization" Version="1.0.2" />
<PackageVersion Include="ImanSoftware.Serialization" Version="1.0.2" />
<PackageReference Include="ImanSoftware.Serialization" />
paket add ImanSoftware.Serialization --version 1.0.2
#r "nuget: ImanSoftware.Serialization, 1.0.2"
#:package ImanSoftware.Serialization@1.0.2
#addin nuget:?package=ImanSoftware.Serialization&version=1.0.2
#tool nuget:?package=ImanSoftware.Serialization&version=1.0.2
ImanSoftware.Serialization
Version: 1.0.0 | Last Updated: August 2026
A flexible JSON serialization abstraction for .NET with support for both System.Text.Json and Newtonsoft.Json.
ImanSoftware.Serialization provides a unified interface for JSON serialization and deserialization, allowing applications to switch between serialization engines without changing business logic. Choose the implementation that best fits your project while keeping your code clean and testable.
Installation
Install the package using the .NET CLI:
dotnet add package ImanSoftware.Serialization
Why Serialization Abstraction?
Tightly coupling your application to a specific JSON library makes future migrations and testing more difficult.
Instead of:
JsonSerializer.Serialize(product);
or
JsonConvert.SerializeObject(product);
Use:
_jsonSerializer.Serialize(product);
This allows the serialization engine to be configured centrally through Dependency Injection.
Benefits include:
- Easily switch between JSON libraries
- Improved testability
- Cleaner architecture
- Dependency Injection friendly
- Consistent serialization API
Features
- ✅
IJsonSerializerabstraction - ✅ JSON serialization
- ✅ JSON deserialization
- ✅
System.Text.Jsonimplementation - ✅
Newtonsoft.Jsonimplementation - ✅ Configurable serializer options
- ✅ Dependency Injection support
- ✅ Easy implementation switching
IJsonSerializer
The core abstraction provides serialization and deserialization methods.
public interface IJsonSerializer
{
string Serialize(object value);
T? Deserialize<T>(string json);
}
SystemTextJsonSerializer
Default implementation based on System.Text.Json.
Features:
- High performance
- Low memory allocations
- Configurable
JsonSerializerOptions - Built into modern .NET
Example:
services.AddJsonSerializer();
NewtonsoftJsonSerializer
Implementation based on Newtonsoft.Json.
Features:
- Mature and feature-rich
- Extensive customization
- Configurable
JsonSerializerSettings - Suitable for legacy and advanced scenarios
Example:
services.AddJsonSerializer(
SerializationDefaultImplementationType.Newtonsoft);
Dependency Injection
Register the default serializer:
services.AddJsonSerializer();
This registers:
System.Text.Json
To use Newtonsoft.Json instead:
services.AddJsonSerializer(
SerializationDefaultImplementationType.Newtonsoft);
Example
using ImanSoftware.Serialization;
public class ProductService
{
private readonly IJsonSerializer _json;
public ProductService(IJsonSerializer json)
{
_json = json;
}
public string Serialize(Product product)
{
return _json.Serialize(product);
}
public Product? Deserialize(string json)
{
return _json.Deserialize<Product>(json);
}
}
Unit Testing
Because serialization is abstracted behind an interface, it can easily be mocked.
var mock = new Mock<IJsonSerializer>();
mock.Setup(x => x.Serialize(It.IsAny<Product>()))
.Returns("{\"id\":1}");
This keeps tests isolated from any specific serialization library.
Design Goals
- Serializer-agnostic
- High performance
- Dependency Injection friendly
- Clean Architecture compatible
- Easy to configure
- Lightweight
- Mock-friendly
- Extensible
- Consistent API
Requirements
- .NET Standard 2.0+
- .NET 6+
- .NET 7+
- .NET 8+
- .NET 9+
- .NET 10.0+
Author
Iman Estiri
📧 contact.imanestiri@gmail.com
📧 dev.imanestiri@gmail.com
GitHub:
License
This project is licensed under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.10)
- Newtonsoft.Json (>= 13.0.4)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on ImanSoftware.Serialization:
| Package | Downloads |
|---|---|
|
ImanSoftware.Framework
Umbrella package that bundles all ImanSoftware modules for a unified development experience. |
|
|
ImanSoftware.Caching
In-memory caching abstraction built on IMemoryCache, with a clean GetOrSet pattern. |
GitHub repositories
This package is not used by any popular GitHub repositories.