Json2Sharp 1.1.8

There is a newer version of this package available.
See the version list below for details.
dotnet add package Json2Sharp --version 1.1.8                
NuGet\Install-Package Json2Sharp -Version 1.1.8                
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.1.8" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Json2Sharp --version 1.1.8                
#r "nuget: Json2Sharp, 1.1.8"                
#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 Json2Sharp as a Cake Addin
#addin nuget:?package=Json2Sharp&version=1.1.8

// Install Json2Sharp as a Cake Tool
#tool nuget:?package=Json2Sharp&version=1.1.8                

NuGet Badge NuGet Nightly Badge

Json2Sharp

Json2Sharp is a library that converts a JSON object to a programming language type definition (i.e. a class).

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,
        TargetType = CSharpObjectType.Record,
        SerializationAttribute = CSharpSerializationAttribute.NewtonsoftJson
    }
};

string code = Json2Sharp.Parse(className, rawJson, options);
/*
 * using Newtonsoft.Json;
 *
 * public record Person(
 *     [JsonProperty("id")] int Id,
 *     [JsonProperty("name")] string Name
 * );
 */
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.
  • net8.0

    • No dependencies.

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.1.12-nightly-054 32 8/10/2024
1.1.12-nightly-053 33 8/9/2024
1.1.11 60 6/7/2024
1.1.11-nightly-051 46 6/7/2024
1.1.10 70 5/22/2024
1.1.10-nightly-046 53 5/22/2024
1.1.10-nightly-045 54 5/22/2024
1.1.10-nightly-044 50 5/21/2024
1.1.9 70 5/13/2024
1.1.9-nightly-040 54 5/13/2024
1.1.8 80 5/7/2024
1.1.8-nightly-039 59 5/7/2024
1.1.8-nightly-038 51 5/7/2024
1.1.8-nightly-037 52 5/7/2024
1.1.8-nightly-036 55 5/7/2024
1.1.8-nightly-035 63 5/6/2024
1.1.7 91 2/10/2024
1.1.7-nightly-031 60 2/14/2024
1.1.7-nightly-030 48 2/10/2024
1.1.7-nightly-029 49 2/10/2024
1.1.6 126 12/27/2023
1.1.6-nightly-027 57 12/27/2023
1.1.5 70 12/27/2023
1.1.5-nightly-026 65 12/27/2023
1.1.4 65 12/26/2023
1.1.4-nightly-025 58 12/26/2023
1.1.2 92 12/26/2023
1.1.2-nightly-021 63 12/26/2023
1.1.1 89 12/23/2023
1.1.1-nightly-020 67 12/23/2023
1.1.1-nightly-018 61 12/23/2023
1.1.0 91 12/23/2023
1.1.0-nightly-015 59 12/23/2023
1.1.0-nightly-011 65 12/22/2023
1.0.2-nightly-010 61 12/21/2023
1.0.1 91 12/19/2023
1.0.1-nightly-09 54 12/21/2023
1.0.1-nightly-08 62 12/19/2023
1.0.0 81 12/19/2023
1.0.0-nightly-04 70 12/19/2023
0.0.1-nightly-03 69 12/19/2023