Universal.Common.Json
1.0.1
See the version list below for details.
dotnet add package Universal.Common.Json --version 1.0.1
NuGet\Install-Package Universal.Common.Json -Version 1.0.1
<PackageReference Include="Universal.Common.Json" Version="1.0.1" />
paket add Universal.Common.Json --version 1.0.1
#r "nuget: Universal.Common.Json, 1.0.1"
// Install Universal.Common.Json as a Cake Addin #addin nuget:?package=Universal.Common.Json&version=1.0.1 // Install Universal.Common.Json as a Cake Tool #tool nuget:?package=Universal.Common.Json&version=1.0.1
Universal.Common.Json
This package provides a JsonSchema
class that represents a JSON Schema according to the Draft 2020-12 specification. It allows you to create, serialize, and deserialize JSON Schemas in your .NET applications.
Features
- Full support for JSON Schema Draft 2020-12
- Serialization and deserialization using both Newtonsoft.Json and System.Text.Json
- Extension data support for custom keywords
Usage
Here's a basic example of how to create and serialize a JSON Schema:
using Universal.Common.Json;
using System.Text.Json;
var schema = new JsonSchema
{
Title = "Person",
Type = "object",
Properties = new Dictionary<string, JsonSchema>
{
["name"] = new JsonSchema { Type = "string" },
["age"] = new JsonSchema { Type = "integer", Minimum = 0 },
["email"] = new JsonSchema { Type = "string", Format = "email" }
},
Required = new[] { "name", "email" }
};
string jsonString = JsonSerializer.Serialize(schema);
Console.WriteLine(jsonString);
You can also deserialize a JSON string into a JsonSchema
object:
string jsonString = @"{
""$schema"": ""https://json-schema.org/draft/2020-12/schema"",
""title"": ""Person"",
""type"": ""object"",
""properties"": {
""name"": { ""type"": ""string"" },
""age"": { ""type"": ""integer"", ""minimum"": 0 },
""email"": { ""type"": ""string"", ""format"": ""email"" }
},
""required"": [""name"", ""email""]
}";
JsonSchema schema = JsonSerializer.Deserialize<JsonSchema>(jsonString);
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. |
-
net8.0
- Newtonsoft.Json (>= 13.0.3)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Universal.Common.Json:
Package | Downloads |
---|---|
Universal.OpenAI.Client
Class library for interacting with OpenAI APIs. |
|
Universal.Anthropic.Client
Class library for interacting with the Anthropic REST API. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Initial release supporting JsonSchema.