Neemle.Utils.JsonTransformer 1.0.1

dotnet add package Neemle.Utils.JsonTransformer --version 1.0.1
                    
NuGet\Install-Package Neemle.Utils.JsonTransformer -Version 1.0.1
                    
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="Neemle.Utils.JsonTransformer" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Neemle.Utils.JsonTransformer" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Neemle.Utils.JsonTransformer" />
                    
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 Neemle.Utils.JsonTransformer --version 1.0.1
                    
#r "nuget: Neemle.Utils.JsonTransformer, 1.0.1"
                    
#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 Neemle.Utils.JsonTransformer@1.0.1
                    
#: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=Neemle.Utils.JsonTransformer&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Neemle.Utils.JsonTransformer&version=1.0.1
                    
Install as a Cake Tool

Neemle.Utils.JsonTransformer

A library for simple JSON serialization and deserialization with code trimming support in .NET 9.

Size Optimization

This library is optimized for minimal size using the following technologies:

  • PublishTrimmed - removal of unused code
  • TrimMode=link - aggressive trimming mode for maximum size reduction
  • InvariantGlobalization - removal of unnecessary localization resources
  • OptimizationPreference=Size - optimization for size instead of performance
  • DebuggerSupport=false - removal of debugging support

Code Trimming Support

This library supports code trimming in .NET 9 with two approaches:

1. Regular Methods (with code trimming warnings)

These methods have the RequiresUnreferencedCode attribute, which may cause warnings when code trimming is enabled:

// This may cause IL2026 warnings when code trimming is enabled
var json = JsonTransformer.Encode(person);
var person = JsonTransformer.Decode<Person>(json);

2. Trimming-Safe Methods (using JsonTypeInfo)

These methods do not cause warnings when code trimming is enabled, but require the use of JsonTypeInfo or JsonSerializerContext:

// Creating a serialization context
// The Default property is automatically generated in each derived class
[JsonSerializable(typeof(Person))]
public partial class PersonContext : JsonTransformerContext<Person> {}

// Usage in code (without IL2026 warnings)
var json = JsonTransformer.Encode(person, PersonContext.Default.Person);
var person = JsonTransformer.Decode(json, PersonContext.Default.Person);

Features

Methods with Warnings During Code Trimming

  • JsonTransformer.Encode<T>(obj, options) - serialization of an object to a JSON string
  • JsonTransformer.Decode<T>(json, options) - deserialization of a JSON string to an object
  • JsonTransformerOptions.PrettyPrint - options for formatted JSON (safe for code trimming)
  • JsonTransformerOptions.SingleLine - options for single-line JSON (safe for code trimming)

Trimming-Safe Methods

  • JsonTransformer.Encode<T>(obj, jsonTypeInfo) - serialization of an object to a JSON string
  • JsonTransformer.Decode<T>(json, jsonTypeInfo) - deserialization of a JSON string to an object
  • JsonTransformerOptions.CreatePrettyPrintOptions() - creating options for formatted JSON
  • JsonTransformerOptions.CreateSingleLineOptions() - creating options for single-line JSON
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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.
  • net9.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Neemle.Utils.JsonTransformer:

Package Downloads
Neemle.Utils.Settings

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 158 6/4/2025
1.0.0 204 3/9/2025