Purview.ZodSharp.NewtonsoftJson
2.3.0
See the version list below for details.
dotnet add package Purview.ZodSharp.NewtonsoftJson --version 2.3.0
NuGet\Install-Package Purview.ZodSharp.NewtonsoftJson -Version 2.3.0
<PackageReference Include="Purview.ZodSharp.NewtonsoftJson" Version="2.3.0" />
<PackageVersion Include="Purview.ZodSharp.NewtonsoftJson" Version="2.3.0" />
<PackageReference Include="Purview.ZodSharp.NewtonsoftJson" />
paket add Purview.ZodSharp.NewtonsoftJson --version 2.3.0
#r "nuget: Purview.ZodSharp.NewtonsoftJson, 2.3.0"
#:package Purview.ZodSharp.NewtonsoftJson@2.3.0
#addin nuget:?package=Purview.ZodSharp.NewtonsoftJson&version=2.3.0
#tool nuget:?package=Purview.ZodSharp.NewtonsoftJson&version=2.3.0
Purview.ZodSharp.NewtonsoftJson
Newtonsoft.Json integration for Purview.ZodSharp . Deserialize-and-validate JSON in a single pass, create validating
JsonConverter instances, and import JSON Schema definitions (Z.FromJsonSchema).
Installation
dotnet add package Purview.ZodSharp.NewtonsoftJson
Deserialize and validate
using ZodSharp;
var userSchema = Z.Object()
.Field("name", Z.String().Min(3))
.Field("age", Z.Number().Min(0).Int())
.Build();
var json = """{ "name": "John", "age": 30 }""";
var result = userSchema.DeserializeAndValidate(json);
if (result.IsSuccess)
Console.WriteLine($"Valid: {result.Value}");
Async stream overload and JToken overload:
await using var stream = File.OpenRead("user.json");
var result = await userSchema.DeserializeAndValidateAsync(stream);
var jToken = JObject.Parse(json);
var result2 = userSchema.DeserializeAndValidate(jToken);
Validating converter
var converter = userSchema.CreateValidatingConverter();
var value = JsonConvert.DeserializeObject<User>(json, converter);
UTC DateTimeOffset contract
The default PreserveOffset schema is exact and needs no converter. When the generated JSON Schema uses
DateTimeOffsetSerialization.Utc, add the matching converter so the serializer writes UTC and rejects a value
without an explicit Z/zero offset (or with a non-zero offset) on read:
using Newtonsoft.Json;
using ZodSharp.Json.Serialization.NewtonsoftJson;
var settings = new JsonSerializerSettings().UseZodSharpUtcDateTimeOffset();
The helper sets DateParseHandling = DateParseHandling.None, which is required so the converter can inspect
the original offset, and adds the UTC converter. UseZodSharpPreserveOffsetDateTimeOffset() is the
per-type/property opt-out equivalent.
PreserveOffsetDateTimeOffsetConverter is available to opt a type or property back out of a project-wide UTC
converter. See JSON Schema Export.
Import from JSON Schema
using ZodSharp;
using ZodSharp.JsonSchema.NewtonsoftJson;
var schema = Z.FromJsonSchema(jsonSchemaString);
var result = schema.Validate(data);
This lets you share schemas defined in TypeScript/Zod with your .NET backend. (Export via Z.ToJsonSchema lives in the core package.)
Documentation
License
MIT — see the package metadata in Purview.ZodSharp.NewtonsoftJson on NuGet.
| 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. net11.0 is compatible. |
-
net10.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.13)
- Microsoft.Extensions.Options (>= 10.0.13)
- Newtonsoft.Json (>= 13.0.4)
- Purview.ZodSharp (>= 2.3.0)
-
net11.0
- Newtonsoft.Json (>= 13.0.4)
- Purview.ZodSharp (>= 2.3.0)
-
net8.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Options (>= 8.0.2)
- Newtonsoft.Json (>= 13.0.4)
- Purview.ZodSharp (>= 2.3.0)
-
net9.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.20)
- Microsoft.Extensions.Options (>= 9.0.20)
- Newtonsoft.Json (>= 13.0.4)
- Purview.ZodSharp (>= 2.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 |
|---|---|---|
| 2.4.2 | 66 | 10/26/2026 |
| 2.4.1 | 84 | 10/23/2026 |
| 2.4.0 | 264 | 10/22/2026 |
| 2.3.0 | 87 | 10/22/2026 |
| 2.2.0 | 101 | 10/18/2026 |
| 2.1.0 | 91 | 10/16/2026 |
| 2.0.2 | 116 | 10/8/2026 |
| 2.0.1.1 | 96 | 10/7/2026 |
| 2.0.1 | 93 | 10/7/2026 |
| 2.0.0 | 92 | 9/29/2026 |
| 2.0.0-prerelease.28 | 66 | 9/28/2026 |
| 2.0.0-prerelease.27 | 73 | 9/27/2026 |
| 2.0.0-prerelease.26 | 73 | 9/27/2026 |
| 2.0.0-prerelease.25 | 65 | 9/27/2026 |
| 2.0.0-prerelease.24 | 79 | 9/25/2026 |
| 2.0.0-prerelease.23 | 73 | 9/25/2026 |
| 2.0.0-prerelease.22 | 64 | 9/24/2026 |
| 2.0.0-prerelease.21 | 72 | 9/24/2026 |
| 2.0.0-prerelease.20 | 80 | 9/23/2026 |
| 2.0.0-prerelease.19 | 76 | 9/23/2026 |