using System.Text.Json;
{
"id": 1,
"number": 20000004,
"bagGUID": null
}
public class Barcode
{
public long Id { get; set; }
public long Number { get; set; }
#nullable enable
public string? BagGUID { get; set; }
}
using System;
using System.Text.Json;
using System.Text.Json.Serialization;
var json = "{\"id\":1,\"number\":42,\"bagGUID\":null}";
var data = JsonSerializer.Deserialize<Barcode>(json);
Console.WriteLine(data!.ToString()); // выведет "Barcode { Id = 1, Number = 42, BagGuid = }"
record Barcode
{
[JsonPropertyName("id")]
public int Id { get; init; }
[JsonPropertyName("number")]
public int Number { get; init; }
[JsonPropertyName("bagGUID")]
public Guid? BagGuid { get; init; }
}