Dev.Util.Json
1.2.2
See the version list below for details.
dotnet add package Dev.Util.Json --version 1.2.2
NuGet\Install-Package Dev.Util.Json -Version 1.2.2
<PackageReference Include="Dev.Util.Json" Version="1.2.2" />
<PackageVersion Include="Dev.Util.Json" Version="1.2.2" />
<PackageReference Include="Dev.Util.Json" />
paket add Dev.Util.Json --version 1.2.2
#r "nuget: Dev.Util.Json, 1.2.2"
#:package Dev.Util.Json@1.2.2
#addin nuget:?package=Dev.Util.Json&version=1.2.2
#tool nuget:?package=Dev.Util.Json&version=1.2.2
Dev.Util.Json
Streamlined JSON serialization and deep-copying utilities for the Dev.Util ecosystem. Built on System.Text.Json for ultimate performance.
📦 Installation
dotnet add package Dev.Util.Json
✨ Features
- 🚀 Fluent Serialization:
ToJson()andFromJson<T>()extensions for all objects. - 🧬 Deep Cloning: Create absolute, disconnected copies of complex object graphs.
- ⚙️ Configurable: Access global or per-call
JsonSerializerOptions. - 📦 Clean Deserialization: Handles nulls and generic types gracefully.
🛠 Usage Examples
1. Quick Serialization
Convert any object to a JSON string without setting up converters.
using Dev.Util.Json;
var profile = new { ID = 101, Role = "Developer", Active = true };
string json = profile.ToJson();
// Output: {"ID":101,"Role":"Developer","Active":true}
// With formatting (Pretty Print)
string pretty = profile.ToJson(indented: true);
2. Safe Deserialization
Parse strings back into objects or dynamics.
using Dev.Util.Json;
string rawBody = "{\"Name\":\"Alice\",\"Tags\":[\"C#\",\"DotNet\"]}";
var user = rawBody.FromJson<User>();
Console.WriteLine(user.Name); // Alice
3. The Power of Deep Cloning
Create a duplicate of an object that shares NO memory references with the original. Uses JSON serialization for the most reliable copy.
using Dev.Util.Json;
var original = new Order {
ID = 1,
Products = new List<Product> { new Product { Name = "Tool" } }
};
// Create a deep copy
var backup = original.DeepClone();
// Modifying the backup DOES NOT change the original
backup.Products[0].Name = "Modified";
Console.WriteLine(original.Products[0].Name); // "Tool" (unchanged)
4. Working with Anonymous Types
string json = "{\"key\":\"value\"}";
var obj = json.FromJson<dynamic>();
DeepClone() requires that your object properties have public getters/setters and a parameterless constructor (or compatible with System.Text.Json).
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Dev.Util.Core (>= 1.2.2)
- System.Text.Json (>= 8.0.0)
-
net8.0
- Dev.Util.Core (>= 1.2.2)
- System.Text.Json (>= 8.0.0)
-
net9.0
- Dev.Util.Core (>= 1.2.2)
- System.Text.Json (>= 8.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Dev.Util.Json:
| Package | Downloads |
|---|---|
|
Dev.Util
The complete Dev.Util ecosystem for .NET. One package to rule them all. Provides access to Core, Collections, IO, Security, Web, Reflection, Tasks, and Json modules. |
GitHub repositories
This package is not used by any popular GitHub repositories.