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.
<PackageVersion Include="Universal.Common.Json" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Universal.Common.Json" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version 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.
#:package Universal.Common.Json@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Universal.Common.Json&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Universal.Common.Json&version=1.0.1
                    
Install as a Cake Tool

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.  net9.0 was computed.  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 was computed.  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. 
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 890 11/13/2024
1.4.0 134 11/11/2024
1.3.0 116 11/6/2024
1.2.0 105 11/6/2024
1.1.0 113 10/30/2024
1.0.2 293 9/4/2024
1.0.1 136 9/4/2024

Initial release supporting JsonSchema.