Json2Sharp 1.2.0-nightly-057

This is a prerelease version of Json2Sharp.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Json2Sharp --version 1.2.0-nightly-057
                    
NuGet\Install-Package Json2Sharp -Version 1.2.0-nightly-057
                    
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="Json2Sharp" Version="1.2.0-nightly-057" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Json2Sharp" Version="1.2.0-nightly-057" />
                    
Directory.Packages.props
<PackageReference Include="Json2Sharp" />
                    
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 Json2Sharp --version 1.2.0-nightly-057
                    
#r "nuget: Json2Sharp, 1.2.0-nightly-057"
                    
#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 Json2Sharp@1.2.0-nightly-057
                    
#: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=Json2Sharp&version=1.2.0-nightly-057&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Json2Sharp&version=1.2.0-nightly-057&prerelease
                    
Install as a Cake Tool

NuGet Badge NuGet Nightly Badge

Json2Sharp

Json2Sharp is a library that converts a JSON object to a class definition (or an equivalent for the target language).

To perform a conversion, call the Parse method from the Json2Sharp class.

string code = Json2Sharp.Parse("Person", """{ "id": 1, "name": "John" }""");
/*
 * using System.Text.Json.Serialization;
 *
 * public sealed record Person(
 *     [property: JsonPropertyName("id")] int Id,
 *     [property: JsonPropertyName("name")] bool Name
 * );
 */

You can also customize the conversion by initializing a Json2SharpOptions object and populating its members to suit your needs.

Json2SharpOptions options = new()
{
    TargetLanguage = Language.CSharp,
    CSharpOptions = new()
    {
        IsSealed = false,
        IsPropertyRequired = false,
        TargetType = CSharpObjectType.Class,
        SerializationAttribute = CSharpSerializationAttribute.NewtonsoftJson
    }
};

string code = Json2Sharp.Parse(className, rawJson, options);
/*
 * using Newtonsoft.Json;
 *
 * public sealed class Person
 * {
 *     [JsonProperty("id")]
 *     public int Id { get; init; }
 *
 *     [JsonProperty("name")]
 *     public string Name { get; init; }
 * }
 */
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 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 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

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.2.0-nightly-058 27 9/16/2025
1.2.0-nightly-057 18 9/15/2025
1.2.0-nightly-056 15 9/14/2025
1.1.12-nightly-054 92 8/10/2024
1.1.12-nightly-053 85 8/9/2024
1.1.11 144 6/7/2024
1.1.11-nightly-051 78 6/7/2024
1.1.10 105 5/22/2024
1.1.10-nightly-046 82 5/22/2024
1.1.10-nightly-045 88 5/22/2024
1.1.10-nightly-044 81 5/21/2024
1.1.9 109 5/13/2024
1.1.9-nightly-040 82 5/13/2024
1.1.8 117 5/7/2024
1.1.8-nightly-039 86 5/7/2024
1.1.8-nightly-038 84 5/7/2024
1.1.8-nightly-037 83 5/7/2024
1.1.8-nightly-036 85 5/7/2024
1.1.8-nightly-035 91 5/6/2024
1.1.7 128 2/10/2024
1.1.7-nightly-031 90 2/14/2024
1.1.7-nightly-030 77 2/10/2024
1.1.7-nightly-029 78 2/10/2024
1.1.6 157 12/27/2023
1.1.6-nightly-027 85 12/27/2023
1.1.5 100 12/27/2023
1.1.5-nightly-026 91 12/27/2023
1.1.4 95 12/26/2023
1.1.4-nightly-025 83 12/26/2023
1.1.2 120 12/26/2023
1.1.2-nightly-021 90 12/26/2023
1.1.1 122 12/23/2023
1.1.1-nightly-020 92 12/23/2023
1.1.1-nightly-018 91 12/23/2023
1.1.0 122 12/23/2023
1.1.0-nightly-015 85 12/23/2023
1.1.0-nightly-011 95 12/22/2023
1.0.2-nightly-010 89 12/21/2023
1.0.1 120 12/19/2023
1.0.1-nightly-09 84 12/21/2023
1.0.1-nightly-08 90 12/19/2023
1.0.0 113 12/19/2023
1.0.0-nightly-04 95 12/19/2023
0.0.1-nightly-03 103 12/19/2023