![]() |
VOOZH | about |
dotnet add package Azrng.Core.Json --version 1.3.1
NuGet\Install-Package Azrng.Core.Json -Version 1.3.1
<PackageReference Include="Azrng.Core.Json" Version="1.3.1" />
<PackageVersion Include="Azrng.Core.Json" Version="1.3.1" />Directory.Packages.props
<PackageReference Include="Azrng.Core.Json" />Project file
paket add Azrng.Core.Json --version 1.3.1
#r "nuget: Azrng.Core.Json, 1.3.1"
#:package Azrng.Core.Json@1.3.1
#addin nuget:?package=Azrng.Core.Json&version=1.3.1Install as a Cake Addin
#tool nuget:?package=Azrng.Core.Json&version=1.3.1Install as a Cake Tool
这是一个基于 System.Text.Json 封装的 JSON 序列化库,提供了常用的 JSON 序列化和反序列化功能,并内置了一些常用的转换器。
通过 NuGet 安装:
Install-Package Azrng.Core.Json
或通过 .NET CLI:
dotnet add package Azrng.Core.Json
在 Program.cs 或 Startup.cs 中注册服务:
// 基本配置
services.ConfigureDefaultJson();
// 自定义配置
services.ConfigureDefaultJson(options =>
{
// 自定义序列化选项
options.JsonSerializeOptions.WriteIndented = true;
options.JsonDeserializeOptions.PropertyNameCaseInsensitive = false;
});
注入IJsonSerializer接口并在代码中使用:
public class MyService
{
private readonly IJsonSerializer _jsonSerializer;
public MyService(IJsonSerializer jsonSerializer)
{
_jsonSerializer = jsonSerializer;
}
public void DoSomething()
{
var obj = new MyObject { Name = "test" };
// 序列化对象
string json = _jsonSerializer.ToJson(obj);
// 反序列化对象
var deserializedObj = _jsonSerializer.ToObject<MyObject>(json);
// 对象深拷贝
var clonedObj = _jsonSerializer.Clone(obj);
// 反序列化为列表
var list = _jsonSerializer.ToList<MyObject>("[{\"Name\":\"item1\"},{\"Name\":\"item2\"}]");
}
}
除了通过依赖注入使用外,还提供了一个静态帮助类用于对象深拷贝:
using Azrng.Core.Json.Utils;
var obj = new MyObject { Name = "test" };
var clonedObj = JsonHelper.Clone(obj);
该库包含以下内置转换器:
可以通过自定义配置添加这些转换器:
services.ConfigureDefaultJson(options =>
{
options.JsonSerializeOptions.Converters.Add(new LongToStringConverter());
options.JsonDeserializeOptions.Converters.Add(new LongToStringConverter());
});
1.3.1
1.3.0
1.2.6
1.2.6-beta2
1.2.6-beta1
1.2.5
1.2.4
1.2.3
1.2.2
1.2.1
1.2.0
1.1.0
1.0.1-beta2
1.0.1-beta1
1.0.0
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 net6.0 is compatible. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 is compatible. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.3.1 | 154 | 3/2/2026 |
| 1.3.0 | 124 | 1/26/2026 |
| 1.2.6 | 612 | 12/1/2025 |
| 1.2.6-beta2 | 375 | 11/12/2025 |
| 1.2.6-beta1 | 180 | 11/6/2025 |
| 1.2.5 | 144 | 10/25/2025 |
| 1.2.4 | 220 | 10/13/2025 |
| 1.2.3 | 219 | 10/8/2025 |
| 1.2.2 | 351 | 9/18/2025 |
| 1.2.1 | 279 | 8/26/2025 |
| 1.2.0 | 227 | 8/24/2025 |
| 1.1.0 | 250 | 3/20/2025 |
| 1.1.0-beta2 | 179 | 2/12/2025 |
| 1.1.0-beta1 | 159 | 12/23/2024 |
| 1.0.0 | 268 | 11/28/2024 |