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
<PackageReference Include="Neemle.Utils.JsonTransformer" Version="1.0.1" />
<PackageVersion Include="Neemle.Utils.JsonTransformer" Version="1.0.1" />
<PackageReference Include="Neemle.Utils.JsonTransformer" />
paket add Neemle.Utils.JsonTransformer --version 1.0.1
#r "nuget: Neemle.Utils.JsonTransformer, 1.0.1"
#:package Neemle.Utils.JsonTransformer@1.0.1
#addin nuget:?package=Neemle.Utils.JsonTransformer&version=1.0.1
#tool nuget:?package=Neemle.Utils.JsonTransformer&version=1.0.1
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 codeTrimMode=link
- aggressive trimming mode for maximum size reductionInvariantGlobalization
- removal of unnecessary localization resourcesOptimizationPreference=Size
- optimization for size instead of performanceDebuggerSupport=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 stringJsonTransformer.Decode<T>(json, options)
- deserialization of a JSON string to an objectJsonTransformerOptions.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 stringJsonTransformer.Decode<T>(json, jsonTypeInfo)
- deserialization of a JSON string to an objectJsonTransformerOptions.CreatePrettyPrintOptions()
- creating options for formatted JSONJsonTransformerOptions.CreateSingleLineOptions()
- creating options for single-line JSON
Product | Versions 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. |
-
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.