Sparkdo.Json 2.0.0-preview.2

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

Sparkdo.Json

Sparkdo.Json 是 source-generated JSON resolver 的运行时产品包。它把 generated contributors 组合为命名 JsonSerializerOptions,并提供默认 IJsonSerializer

职责

  • 通过 SparkdoJsonManifest 声明 runtime、默认 serializer 与 application bootstrap contribution。
  • 由 application bootstrap 注册 options 基础设施与 generated contributors。
  • JsonOptionsBuilder 组合 generated 或手动 resolver contribution。
  • SparkdoJsonSerializerOptions 配置 default 或 named options。
  • JsonSerializationRuntime 缓存并解析 JsonTypeInfo
  • DefaultJsonSerializer 提供同步、Type 和 stream 异步序列化。

非职责

  • 不扫描程序集发现 JsonSerializerContext
  • 不回退到 reflection-based serialization。
  • 不允许 options callback 替代 generated resolver chain;resolver 必须通过 JsonOptionsBuilder.AddResolver(...) 注册。
  • 不拥有 context discovery 或 generated source emission。
  • 运行时产品程序集不依赖 Hosting,也不提供公共 bootstrap helper。

关键入口

API 用途
SparkdoJsonManifest 声明 runtime、serializer 和 application bootstrap contribution。
IJsonOptionsContributor 向运行时交付 generated 或手写 resolver。
SparkdoJsonSerializerOptions.ConfigureDefault(...) 配置 default options。
SparkdoJsonSerializerOptions.Configure(name, ...) 配置 named options。
IJsonSerializer 执行 source-generated JSON 序列化。

集成

using System.Text.Json.Serialization;
using Sparkdo.Json;

[SparkdoJsonContext]
[JsonSerializable(typeof(Order))]
internal partial class ApplicationJsonContext : JsonSerializerContext;

编译器为 context 生成 public IJsonOptionsContributor 实现,并在 Application role 生成固定 bootstrap contribution,把当前项目与引用程序集的 generated contributors 注册到运行时集合。手写 contributor 不参与生成器发现,应在入口程序显式注册。

手动配置仍使用标准 options 注册链:

builder.Services.Configure<SparkdoJsonSerializerOptions>(options =>
    options.ConfigureDefault(json => json.WriteIndented = true));

运行时对未注册类型和跨 name 歧义 fail closed,不会退回反射序列化。

依赖

运行时面向 net10.0,依赖 Sparkdo.Json.AbstractionsSparkdo.ManifestMicrosoft.Extensions.OptionsSystem.Text.Json。包同时携带 Sparkdo.Json.Compiler analyzer。

验证

dotnet test src/json/test/Sparkdo.Json.Tests/Sparkdo.Json.Tests.csproj --no-restore -p:UseSharedCompilation=false -nr:false
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 (12)

Showing the top 5 NuGet packages that depend on Sparkdo.Json:

Package Downloads
Sparkdo.Localization

Sparkdo Localization 的 VFS JSON runtime、文化回退与 package manifest。

Sparkdo.Caching

Sparkdo Caching 分布式缓存 API、默认内存分布式 provider 与 package manifest。

Sparkdo.BackgroundJobs

Sparkdo 后台作业库,提供后台任务调度和执行功能实现

Sparkdo.Kafka

Sparkdo Kafka 集成库,提供 Kafka 消息队列的生产者和消费者功能实现

Sparkdo.AspNetCore

Sparkdo ASP.NET Core 集成库,提供与 ASP.NET Core 框架深度集成的功能实现

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0-preview.2 79 7/20/2026
2.0.0-preview.1 64 7/18/2026
1.0.4-preview.3 262 6/8/2026
1.0.4-preview.2 243 6/7/2026
1.0.4-preview.1 260 6/7/2026
1.0.3 588 6/6/2026
1.0.3-preview.1 272 5/17/2026
1.0.2 481 4/27/2026
1.0.2-preview.5 125 4/15/2026
1.0.2-preview.4 138 2/8/2026
1.0.2-preview.3 132 2/1/2026
1.0.2-preview.2 142 1/31/2026
1.0.2-preview.1 207 12/4/2025
1.0.1 1,403 11/27/2025
1.0.0 1,351 11/25/2025
1.0.0-preview.5 146 10/24/2025