![]() |
VOOZH | about |
dotnet add package Quartz.Serialization.SystemTextJson --version 3.18.1
NuGet\Install-Package Quartz.Serialization.SystemTextJson -Version 3.18.1
<PackageReference Include="Quartz.Serialization.SystemTextJson" Version="3.18.1" />
<PackageVersion Include="Quartz.Serialization.SystemTextJson" Version="3.18.1" />Directory.Packages.props
<PackageReference Include="Quartz.Serialization.SystemTextJson" />Project file
paket add Quartz.Serialization.SystemTextJson --version 3.18.1
#r "nuget: Quartz.Serialization.SystemTextJson, 3.18.1"
#:package Quartz.Serialization.SystemTextJson@3.18.1
#addin nuget:?package=Quartz.Serialization.SystemTextJson&version=3.18.1Install as a Cake Addin
#tool nuget:?package=Quartz.Serialization.SystemTextJson&version=3.18.1Install as a Cake Tool
::: tip JSON is recommended persistent format to store data in database for greenfield projects. You should also strongly consider setting useProperties to true to restrict key-values to be strings. :::
Quartz.Serialization.SystemTextJson provides JSON serialization support for job stores using System.Text.Json facilities to handle the actual serialization process.
You need to add NuGet package reference to your project which uses Quartz.
Install-Package Quartz.Serialization.SystemTextJson
Classic property-based configuration
var properties = new NameValueCollection
{
["quartz.jobStore.type"] = "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz",
["quartz.serializer.type"] = "stj"
};
ISchedulerFactory schedulerFactory = new StdSchedulerFactory(properties);
Configuring using scheduler builder
var config = SchedulerBuilder.Create();
config.UsePersistentStore(store =>
{
// it's generally recommended to stick with
// string property keys and values when serializing
store.UseProperties = true;
store.UseGenericDatabase(dbProvider, db =>
db.ConnectionString = "my connection string"
);
store.UseSystemTextJsonSerializer();
});
ISchedulerFactory schedulerFactory = config.Build();
There's now official solution for migration as there can be quirks in every setup, but there's a recipe that can work for you.
MigratorSerializer below that can read binary serialization format and writes JSON formatExample hybrid serializer
using System.Text.Json;
using Quartz.Simpl;
using Quartz.Spi;
namespace Quartz;
public sealed class MigratorSerializer : IObjectSerializer
{
private readonly BinaryObjectSerializer binarySerializer;
private readonly SystemTextJsonObjectSerializer jsonSerializer;
public MigratorSerializer()
{
binarySerializer = new BinaryObjectSerializer();
// you might need custom configuration, see sections about customizing
// in documentation
jsonSerializer = new SystemTextJsonObjectSerializer();
}
public T DeSerialize<T>(byte[] data) where T : class
{
try
{
// Attempt to deserialize data as JSON
return jsonSerializer.DeSerialize<T>(data)!;
}
catch (JsonException)
{
// Presumably, the data was not JSON, we instead use the binary serializer
var binaryData = binarySerializer.DeSerialize<T>(data);
if (binaryData is JobDataMap jobDataMap)
{
// make sure we mark the map as dirty so it will be serialized as JSON next time
jobDataMap[SchedulerConstants.ForceJobDataMapDirty] = "true";
}
return binaryData!;
}
}
public void Initialize()
{
binarySerializer.Initialize();
jsonSerializer.Initialize();
}
public byte[] Serialize<T>(T obj) where T : class
{
return jsonSerializer.Serialize(obj);
}
}
If you need to customize serialization, you need to inherit custom implementation and override CreateSerializerOptions.
class CustomJsonSerializer : SystemTextJsonObjectSerializer
{
protected override JsonSerializerOptions CreateSerializerOptions()
{
var options = base.CreateSerializerOptions();
options.Converters.Add(new MyCustomConverter());
return options;
}
}
And then configure it to use
store.UseSerializer<CustomJsonSerializer>();
// or
"quartz.serializer.type" = "MyProject.CustomJsonSerializer, MyProject"
If you have implemented a custom calendar, you need to implement a ICalendarSerializer for it.
There's a convenience base class CalendarSerializer that you can use the get strongly-typed experience.
Custom calendar and serializer
using System;
using System.Runtime.Serialization;
using System.Text.Json;
using Quartz.Impl.Calendar;
using Quartz.Serialization.SystemTextJson;
[Serializable]
public sealed class CustomCalendar : BaseCalendar
{
public CustomCalendar()
{
}
// binary serialization support
private CustomCalendar(SerializationInfo info, StreamingContext context) : base(info, context)
{
SomeCustomProperty = info?.GetBoolean("SomeCustomProperty") ?? true;
}
public bool SomeCustomProperty { get; set; } = true;
// binary serialization support
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
info?.AddValue("SomeCustomProperty", SomeCustomProperty);
}
}
// JSON serialization support
public sealed class CustomCalendarSerializer : CalendarSerializer<CustomCalendar>
{
protected override CustomCalendar Create(JsonElement jsonElement, JsonSerializerOptions options)
{
return new CustomCalendar();
}
protected override void SerializeFields(Utf8JsonWriter writer, CustomCalendar calendar, JsonSerializerOptions options)
{
writer.WriteBoolean("SomeCustomProperty", calendar.SomeCustomProperty);
}
protected override void DeserializeFields(CustomCalendar calendar, JsonElement jsonElement, JsonSerializerOptions options)
{
calendar.SomeCustomProperty = jsonElement.GetProperty("CustomProperty").GetBoolean();
}
public override string CalendarTypeName => "CustomCalendar";
}
Configuring custom calendar serializer
var config = SchedulerBuilder.Create();
config.UsePersistentStore(store =>
{
store.UseSystemTextJsonSerializer(json =>
{
json.AddCalendarSerializer<CustomCalendar>(new CustomCalendarSerializer());
});
});
// or just globally which is what above code calls
SystemTextJsonObjectSerializer.AddCalendarSerializer<CustomCalendar>(new CustomCalendarSerializer());
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. 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 was computed. 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 was computed. 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 was computed. 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. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 is compatible. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on Quartz.Serialization.SystemTextJson:
| Package | Downloads |
|---|---|
|
CucurbIT.Infrastructure.Jobs
Package Description |
|
|
Reddoxx.Quartz.MongoDbJobStore
MongoDb job-store implementation for the quartz-scheduler |
|
|
Excalibur.Jobs
Consolidated Excalibur job scheduling and orchestration framework. Includes abstractions, core implementations, coordination, workflows, and Quartz integration. |
|
|
Excalibur.Hosting.Jobs
Job hosting infrastructure for Excalibur applications with .NET Worker Service and Web hosting support. |
|
|
Quartz.Dashboard
Quartz.NET Blazor Server Dashboard; Quartz Scheduling Framework for .NET |
Showing the top 3 popular GitHub repositories that depend on Quartz.Serialization.SystemTextJson:
| Repository | Stars |
|---|---|
|
RayWangQvQ/BiliBiliToolPro
B 站(bilibili)自动任务工具,支持docker、青龙、k8s等多种部署方式。全面拥抱AI。敏感肌也能用。
|
|
|
Reaparr/Reaparr
Plex downloader that brings content from any server to yours!
|
|
|
Altinn/altinn-studio
Next generation open source Altinn platform and applications.
|
| Version | Downloads | Last Updated |
|---|---|---|
| 3.18.1 | 189,288 | 4/25/2026 |
| 3.18.0 | 55,597 | 4/11/2026 |
| 3.17.1 | 29,019 | 4/3/2026 |
| 3.17.0 | 43,667 | 3/29/2026 |
| 3.16.1 | 99,414 | 3/4/2026 |
| 3.16.0 | 14,611 | 3/1/2026 |
| 3.15.1 | 588,690 | 10/26/2025 |
| 3.15.0 | 402,183 | 8/3/2025 |
| 3.14.0 | 713,774 | 3/8/2025 |
| 3.13.1 | 524,088 | 11/2/2024 |
| 3.13.0 | 232,649 | 8/10/2024 |
| 3.12.0 | 6,088 | 8/3/2024 |
| 3.11.0 | 47,420 | 7/7/2024 |
| 3.10.0 | 15,128 | 6/26/2024 |