ImanSoftware.Serialization 1.0.2

dotnet add package ImanSoftware.Serialization --version 1.0.2
                    
NuGet\Install-Package ImanSoftware.Serialization -Version 1.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ImanSoftware.Serialization" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ImanSoftware.Serialization" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="ImanSoftware.Serialization" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ImanSoftware.Serialization --version 1.0.2
                    
#r "nuget: ImanSoftware.Serialization, 1.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ImanSoftware.Serialization@1.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ImanSoftware.Serialization&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=ImanSoftware.Serialization&version=1.0.2
                    
Install as a Cake Tool

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

  • IJsonSerializer abstraction
  • ✅ JSON serialization
  • ✅ JSON deserialization
  • System.Text.Json implementation
  • Newtonsoft.Json implementation
  • ✅ 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:

https://github.com/ImanEstiri


License

This project is licensed under the MIT License.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.

Version Downloads Last Updated
1.0.2 281 8/17/2026
1.0.1 114 8/16/2026
1.0.0 139 8/3/2026