using System.Collections.Generic;
using System.Diagnostics;
using System.Text.Json.Serialization;
public static void Main()
const string JsonString = @"
""serialNo"": ""000000000002200878"",
""affiliationOrgCode"": ""OrgCode1""
""serialNo"": ""000000000002201675"",
""affiliationOrgCode"": ""OrgCode1""
var options = new JsonSerializerOptions(JsonSerializerDefaults.Web);
var deserializedClass = JsonSerializer.Deserialize<Root>(JsonString, options);
Debug.Assert(deserializedClass != null);
Debug.Assert("2201675".Equals(deserializedClass.Item[1].SerialNo.Value));
public SerialNo(string serialNo)
if (serialNo == null) throw new ArgumentNullException(nameof(serialNo));
if (string.IsNullOrWhiteSpace(serialNo)) throw new Exception("My exception text");
Value = serialNo.Trim('0');
public string Value { get; set; }
public SerialNo SerialNo { get; set; }
public string AffiliationOrgCode { get; set; }
public List<Item> Item { get; set; }