C# Integration

The C# TypeSchema integration uses the native System.Text.Json implementation, this means you don`t need to install any additional package to use the generated DTOs.

DTO

using System.Text.Json.Serialization;

namespace TypeSchema.DTO;

/// <summary>
/// A simple student struct
/// </summary>
public class Student
{
    [JsonPropertyName("firstName")]
    public string? FirstName { get; set; }

    [JsonPropertyName("lastName")]
    public string? LastName { get; set; }

    [JsonPropertyName("age")]
    public int? Age { get; set; }

}

Integration

using System.Text.Json;

namespace TypeSchema.DTO;

class Program
{
    static void Main()
    {
        string input = File.ReadAllText("./input.json");

        Student student = JsonSerializer.Deserialize<Student>(input);

        string output = JsonSerializer.Serialize<Student>(student);

        File.WriteAllText("./output.json", output);
    }
}