Universal.Common.Json 1.0.1

There is a newer version of this package available.
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                
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="Universal.Common.Json" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Universal.Common.Json --version 1.0.1                
#r "nuget: Universal.Common.Json, 1.0.1"                
#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.
// 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.

Version Downloads Last updated
1.5.0 78 11/13/2024
1.4.0 90 11/11/2024
1.3.0 74 11/6/2024
1.2.0 65 11/6/2024
1.1.0 79 10/30/2024
1.0.2 251 9/4/2024
1.0.1 111 9/4/2024

Initial release supporting JsonSchema.