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; }
}
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);
}
}