ktsu.NJsonSchemaJsonConverter
1.0.17
Prefix Reserved
dotnet add package ktsu.NJsonSchemaJsonConverter --version 1.0.17
NuGet\Install-Package ktsu.NJsonSchemaJsonConverter -Version 1.0.17
<PackageReference Include="ktsu.NJsonSchemaJsonConverter" Version="1.0.17" />
<PackageVersion Include="ktsu.NJsonSchemaJsonConverter" Version="1.0.17" />
<PackageReference Include="ktsu.NJsonSchemaJsonConverter" />
paket add ktsu.NJsonSchemaJsonConverter --version 1.0.17
#r "nuget: ktsu.NJsonSchemaJsonConverter, 1.0.17"
#:package ktsu.NJsonSchemaJsonConverter@1.0.17
#addin nuget:?package=ktsu.NJsonSchemaJsonConverter&version=1.0.17
#tool nuget:?package=ktsu.NJsonSchemaJsonConverter&version=1.0.17
ktsu.NJsonSchemaJsonConverter
A
JsonConverterFactoryfor System.Text.Json that enables seamless serialization and deserialization of NJsonSchemaJsonSchemaobjects.
Introduction
ktsu.NJsonSchemaJsonConverter bridges the gap between NJsonSchema and System.Text.Json. NJsonSchema provides its own JSON parsing and generation methods, but doesn't integrate natively with System.Text.Json.Serialization. This library provides a JsonConverterFactory that allows JsonSchema objects (and subclasses) to be serialized and deserialized as part of larger object graphs using System.Text.Json.JsonSerializer.
Features
- Full JsonSchema round-tripping - Serialize and deserialize
JsonSchemaobjects to/from JSON - Subclass support - Automatically handles any type derived from
JsonSchema - Drop-in integration - Register as a converter in
JsonSerializerOptionsand it just works - Lightweight - Single source file, minimal dependencies
Installation
Package Manager Console
Install-Package ktsu.NJsonSchemaJsonConverter
.NET CLI
dotnet add package ktsu.NJsonSchemaJsonConverter
Package Reference
<PackageReference Include="ktsu.NJsonSchemaJsonConverter" Version="x.y.z" />
Usage Examples
Basic Setup
Register the converter factory in your JsonSerializerOptions:
using ktsu.NJsonSchemaJsonConverter;
using System.Text.Json;
var options = new JsonSerializerOptions
{
Converters = { new NJsonSchemaJsonConverterFactory() }
};
Serializing an Object Containing a JsonSchema
using NJsonSchema;
using System.Text.Json;
public class SchemaContainer
{
public string Name { get; set; } = string.Empty;
public JsonSchema? Schema { get; set; }
}
// Create a schema
var schema = await JsonSchema.FromTypeAsync<MyModel>();
var container = new SchemaContainer
{
Name = "MyModel Schema",
Schema = schema
};
// Serialize - the schema is written as an inline JSON object
string json = JsonSerializer.Serialize(container, options);
Deserializing an Object Containing a JsonSchema
// Deserialize - the schema is parsed back into a JsonSchema object
var result = JsonSerializer.Deserialize<SchemaContainer>(json, options);
// result.Schema is a fully functional JsonSchema instance
Console.WriteLine(result?.Schema?.Properties.Count);
Using with Dependency Injection
services.AddSingleton(new JsonSerializerOptions
{
Converters = { new NJsonSchemaJsonConverterFactory() }
});
How It Works
The converter handles JsonSchema serialization in two directions:
- Writing: Calls
JsonSchema.ToJson()to produce the schema's JSON representation and writes it inline usingWriteRawValue - Reading: Reads the JSON token as a string and parses it using
JsonSchema.FromJsonAsync()to reconstruct the schema object
The factory uses reflection to create type-specific generic converter instances, supporting JsonSchema and any subclass.
API Reference
NJsonSchemaJsonConverterFactory
A JsonConverterFactory that creates converters for JsonSchema and its subclasses.
| Method | Description |
|---|---|
CanConvert(Type) |
Returns true for JsonSchema and any type deriving from it |
CreateConverter(Type, JsonSerializerOptions) |
Creates a type-specific JsonConverter<T> instance via reflection |
Contributing
Contributions are welcome! Here's how you can help:
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Please make sure to update tests as appropriate.
License
This project is licensed under the MIT License - see the LICENSE.md file for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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 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. |
-
net10.0
- NJsonSchema (>= 11.6.1)
- Polyfill (>= 10.3.0)
-
net8.0
- NJsonSchema (>= 11.6.1)
- Polyfill (>= 10.3.0)
-
net9.0
- NJsonSchema (>= 11.6.1)
- Polyfill (>= 10.3.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.17 | 0 | 4/21/2026 |
| 1.0.16 | 86 | 4/13/2026 |
| 1.0.15 | 95 | 4/10/2026 |
| 1.0.14 | 87 | 4/9/2026 |
| 1.0.13 | 83 | 4/8/2026 |
| 1.0.12 | 87 | 4/6/2026 |
| 1.0.11 | 96 | 3/4/2026 |
| 1.0.10 | 95 | 3/2/2026 |
| 1.0.9 | 101 | 2/27/2026 |
| 1.0.8 | 97 | 2/25/2026 |
| 1.0.7 | 93 | 2/23/2026 |
| 1.0.7-pre.1 | 60 | 2/17/2026 |
| 1.0.6 | 103 | 2/16/2026 |
| 1.0.5 | 95 | 2/16/2026 |
| 1.0.4 | 96 | 2/14/2026 |
| 1.0.3 | 101 | 2/14/2026 |
| 1.0.2 | 105 | 2/10/2026 |
| 1.0.2-pre.3 | 57 | 2/8/2026 |
| 1.0.2-pre.2 | 56 | 2/4/2026 |
| 1.0.2-pre.1 | 61 | 2/3/2026 |
## v1.0.17 (patch)
Changes since v1.0.16:
- Bump NJsonSchema from 11.6.0 to 11.6.1 ([@dependabot[bot]](https://github.com/dependabot[bot]))
## v1.0.16 (patch)
Changes since v1.0.15:
- Bump Polyfill from 10.1.1 to 10.3.0 ([@dependabot[bot]](https://github.com/dependabot[bot]))
## v1.0.15 (patch)
Changes since v1.0.14:
- Bump Polyfill from 10.0.0 to 10.1.1 ([@dependabot[bot]](https://github.com/dependabot[bot]))
## v1.0.14 (patch)
Changes since v1.0.13:
- Bump NJsonSchema from 11.5.2 to 11.6.0 ([@dependabot[bot]](https://github.com/dependabot[bot]))
## v1.0.13 (patch)
Changes since v1.0.12:
- Bump MSTest.Sdk from 4.1.0 to 4.2.1 ([@dependabot[bot]](https://github.com/dependabot[bot]))
## v1.0.12 (patch)
Changes since v1.0.11:
- Bump Polyfill from 9.23.0 to 10.0.0 ([@dependabot[bot]](https://github.com/dependabot[bot]))
## v1.0.11 (patch)
Changes since v1.0.10:
- Bump Polyfill from 9.22.0 to 9.23.0 ([@dependabot[bot]](https://github.com/dependabot[bot]))
- Bump Polyfill from 9.18.0 to 9.22.0 ([@dependabot[bot]](https://github.com/dependabot[bot]))
- Bump Polyfill from 9.17.0 to 9.18.0 ([@dependabot[bot]](https://github.com/dependabot[bot]))
- Bump Polyfill from 9.15.0 to 9.17.0 ([@dependabot[bot]](https://github.com/dependabot[bot]))
- Bump Polyfill from 9.13.0 to 9.15.0 ([@dependabot[bot]](https://github.com/dependabot[bot]))
## v1.0.10 (patch)
Changes since v1.0.9:
- Bump Polyfill from 9.12.0 to 9.13.0 ([@dependabot[bot]](https://github.com/dependabot[bot]))
## v1.0.9 (patch)
Changes since v1.0.8:
- Bump Polyfill from 9.11.0 to 9.12.0 ([@dependabot[bot]](https://github.com/dependabot[bot]))
## v1.0.8 (patch)
Changes since v1.0.7:
- Bump Polyfill from 9.10.0 to 9.11.0 ([@dependabot[bot]](https://github.com/dependabot[bot]))
## v1.0.7 (patch)
Changes since v1.0.6:
- Bump Polyfill from 9.9.0 to 9.10.0 ([@dependabot[bot]](https://github.com/dependabot[bot]))
- Sync .github\workflows\dotnet.yml ([@KtsuTools](https://github.com/KtsuTools))
## v1.0.7-pre.1 (prerelease)
No significant changes detected since v1.0.7.
## v1.0.6 (patch)
Changes since v1.0.5:
- Merge remote-tracking branch 'refs/remotes/origin/main' ([@ktsu[bot]](https://github.com/ktsu[bot]))
- Sync .github\workflows\dotnet.yml ([@ktsu[bot]](https://github.com/ktsu[bot]))
## v1.0.5 (patch)
Changes since v1.0.4:
- Sync .github\workflows\dotnet.yml ([@ktsu[bot]](https://github.com/ktsu[bot]))
- Sync .github\workflows\dotnet.yml ([@ktsu[bot]](https://github.com/ktsu[bot]))
- Sync .github\workflows\dotnet.yml ([@ktsu[bot]](https://github.com/ktsu[bot]))
- Bump Polyfill from 9.8.1 to 9.9.0 ([@dependabot[bot]](https://github.com/dependabot[bot]))
## v1.0.4 (patch)
Changes since v1.0.3:
- Remove legacy build scripts ([@matt-edmondson](https://github.com/matt-edmondson))
## v1.0.3 (patch)
Changes since v1.0.2:
- Sync .github\workflows\dotnet.yml ([@ktsu[bot]](https://github.com/ktsu[bot]))
- Sync global.json ([@ktsu[bot]](https://github.com/ktsu[bot]))
## v1.0.2 (patch)
Changes since v1.0.1:
- Add edge case and container tests ([@matt-edmondson](https://github.com/matt-edmondson))
- Add serialization and deserialization tests ([@matt-edmondson](https://github.com/matt-edmondson))
- Add CanConvert tests for NJsonSchemaJsonConverterFactory ([@matt-edmondson](https://github.com/matt-edmondson))
- Add test project scaffold ([@matt-edmondson](https://github.com/matt-edmondson))
- Add TAGS.md for NuGet package discoverability ([@matt-edmondson](https://github.com/matt-edmondson))
- Update README.md with installation instructions, usage examples, and API reference ([@matt-edmondson](https://github.com/matt-edmondson))
## v1.0.2-pre.3 (prerelease)
Changes since v1.0.2-pre.2:
- Sync scripts\PSBuild.psm1 ([@ktsu[bot]](https://github.com/ktsu[bot]))
- Sync scripts\update-winget-manifests.ps1 ([@ktsu[bot]](https://github.com/ktsu[bot]))
## v1.0.2-pre.2 (prerelease)
Changes since v1.0.2-pre.1:
- Bump Polyfill from 9.8.0 to 9.8.1 ([@dependabot[bot]](https://github.com/dependabot[bot]))
- Bump MSTest.Sdk from 4.0.2 to 4.1.0 ([@dependabot[bot]](https://github.com/dependabot[bot]))
## v1.0.2-pre.1 (prerelease)
No significant changes detected since v1.0.2.
## v1.0.1 (patch)
Changes since v1.0.0:
- Add CLAUDE.md for project guidance and update package references in Directory.Packages.props and global.json ([@matt-edmondson](https://github.com/matt-edmondson))
- Update configuration files and scripts for improved build and test processes ([@matt-edmondson](https://github.com/matt-edmondson))
## v1.0.1-pre.18 (prerelease)
Changes since v1.0.1-pre.17:
- Merge remote-tracking branch 'refs/remotes/origin/main' ([@ktsu[bot]](https://github.com/ktsu[bot]))
- Sync scripts\PSBuild.psm1 ([@ktsu[bot]](https://github.com/ktsu[bot]))
- Sync .editorconfig ([@ktsu[bot]](https://github.com/ktsu[bot]))
- Sync .gitattributes ([@ktsu[bot]](https://github.com/ktsu[bot]))
- Sync .gitignore ([@ktsu[bot]](https://github.com/ktsu[bot]))
- Sync .mailmap ([@ktsu[bot]](https://github.com/ktsu[bot]))
- Sync .runsettings ([@ktsu[bot]](https://github.com/ktsu[bot]))
## v1.0.1-pre.17 (prerelease)
Changes since v1.0.1-pre.16:
- Update ktsu.Extensions to 1.5.5 ([@dependabot[bot]](https://github.com/dependabot[bot]))
## v1.0.1-pre.16 (prerelease)
Changes since v1.0.1-pre.15:
- Sync scripts\PSBuild.psm1 ([@ktsu[bot]](https://github.com/ktsu[bot]))
- Sync .editorconfig ([@ktsu[bot]](https://github.com/ktsu[bot]))
- Sync .gitattributes ([@ktsu[bot]](https://github.com/ktsu[bot]))
- Sync .gitignore ([@ktsu[bot]](https://github.com/ktsu[bot]))
- Sync .mailmap ([@ktsu[bot]](https://github.com/ktsu[bot]))
- Sync .runsettings ([@ktsu[bot]](https://github.com/ktsu[bot]))
## v1.0.1-pre.15 (prerelease)
Changes since v1.0.1-pre.14:
## v1.0.1-pre.14 (prerelease)
Changes since v1.0.1-pre.13:
## v1.0.1-pre.13 (prerelease)
Changes since v1.0.1-pre.12:
## v1.0.1-pre.12 (prerelease)
Changes since v1.0.1-pre.11:
## v1.0.1-pre.11 (prerelease)
Changes since v1.0.1-pre.10:
## v1.0.1-pre.10 (prerelease)
Changes since v1.0.1-pre.9:
## v1.0.1-pre.9 (prerelease)
Changes since v1.0.1-pre.8:
## v1.0.1-pre.8 (prerelease)
Changes since v1.0.1-pre.7:
## v1.0.1-pre.7 (prerelease)
Changes since v1.0.1-pre.6:
## v1.0.1-pre.6 (prerelease)
Changes since v1.0.1-pre.5:
## v1.0.1-pre.5 (prerelease)
Changes since v1.0.1-pre.4:
## v1.0.1-pre.4 (prerelease)
Changes since v1.0.1-pre.3:
- Bump ktsu.Extensions from 1.5.2 to 1.5.3 in the ktsu group ([@dependabot[bot]](https://github.com/dependabot[bot]))
## v1.0.1-pre.3 (prerelease)
Changes since v1.0.1-pre.2:
## v1.0.1-pre.2 (prerelease)
Changes since v1.0.1-pre.1:
## v1.0.1-pre.1 (prerelease)
No significant changes detected since v1.0.1.
## v1.0.0
Changes since v1.0.0-pre.19:
- Remove obsolete build configuration files and scripts, including Directory.Build.props, Directory.Build.targets, and various PowerShell scripts for metadata and version management. Add copyright information to NJsonSchemaJsonConverter.cs. ([@matt-edmondson](https://github.com/matt-edmondson))
- Update project SDK to ktsu.Sdk.Lib version 1.8.0 ([@matt-edmondson](https://github.com/matt-edmondson))
- Update packages ([@matt-edmondson](https://github.com/matt-edmondson))
- Add LICENSE template ([@matt-edmondson](https://github.com/matt-edmondson))
## v1.0.0-pre.19 (prerelease)
Changes since v1.0.0-pre.18:
- Bump ktsu.Extensions from 1.3.2 to 1.4.0 in the ktsu group ([@dependabot[bot]](https://github.com/dependabot[bot]))
## v1.0.0-pre.18 (prerelease)
Changes since v1.0.0-pre.17:
- Sync scripts\make-version.ps1 ([@ktsu[bot]](https://github.com/ktsu[bot]))
- Sync scripts\make-changelog.ps1 ([@ktsu[bot]](https://github.com/ktsu[bot]))
## v1.0.0-pre.17 (prerelease)
Changes since v1.0.0-pre.16:
- Sync .github\workflows\dotnet.yml ([@ktsu[bot]](https://github.com/ktsu[bot]))
## v1.0.0-pre.16 (prerelease)
Changes since v1.0.0-pre.15:
- Sync scripts\make-version.ps1 ([@ktsu[bot]](https://github.com/ktsu[bot]))
- Sync scripts\make-changelog.ps1 ([@ktsu[bot]](https://github.com/ktsu[bot]))
## v1.0.0-pre.15 (prerelease)
Changes since v1.0.0-pre.14:
- Sync .github\workflows\dotnet.yml ([@ktsu[bot]](https://github.com/ktsu[bot]))
## v1.0.0-pre.14 (prerelease)
Changes since v1.0.0-pre.13:
- Sync .github\workflows\dotnet.yml ([@ktsu[bot]](https://github.com/ktsu[bot]))
## v1.0.0-pre.13 (prerelease)
Changes since v1.0.0-pre.12:
## v1.0.0-pre.12 (prerelease)
Changes since v1.0.0-pre.11:
## v1.0.0-pre.11 (prerelease)
Changes since v1.0.0-pre.10:
- Bump MSTest from 3.7.2 to 3.7.3 ([@dependabot[bot]](https://github.com/dependabot[bot]))
## v1.0.0-pre.10 (prerelease)
Changes since v1.0.0-pre.9:
## v1.0.0-pre.9 (prerelease)
Changes since v1.0.0-pre.8:
## v1.0.0-pre.8 (prerelease)
Changes since v1.0.0-pre.7:
- Bump MSTest from 3.7.1 to 3.7.2 ([@dependabot[bot]](https://github.com/dependabot[bot]))
## v1.0.0-pre.7 (prerelease)
Changes since v1.0.0-pre.6:
## v1.0.0-pre.6 (prerelease)
Changes since v1.0.0-pre.5:
- Bump coverlet.collector from 6.0.3 to 6.0.4 ([@dependabot[bot]](https://github.com/dependabot[bot]))
## v1.0.0-pre.5 (prerelease)
Changes since v1.0.0-pre.4:
## v1.0.0-pre.4 (prerelease)
Changes since v1.0.0-pre.3:
## v1.0.0-pre.3 (prerelease)
Changes since v1.0.0-pre.2:
- Bump MSTest from 3.7.0 to 3.7.1 ([@dependabot[bot]](https://github.com/dependabot[bot]))
## v1.0.0-pre.2 (prerelease)
Changes since v1.0.0-pre.1:
## v1.0.0-pre.1 (prerelease)
No significant changes detected since v1.0.0.
## v0.0.1-pre.1 (prerelease)
- Add mailmap ([@matt-edmondson](https://github.com/matt-edmondson))
- Add automation scripts for metadata generation and project management ([@matt-edmondson](https://github.com/matt-edmondson))
- Initial commit ([@matt-edmondson](https://github.com/matt-edmondson))