Parsing JSON Object with variable properties into strongly typed object

If you must have strongly typed result I would deserialize Profile as a dictionary of superposition of properties

class AbscdeClass
{
    public string A { get; set; }
    public string B { get; set; }
    public string C { get; set; }
    public string D { get; set; }
    public string E { get; set; }
}

class JsonBody
{
    public Dictionary<string, AbscdeClass> Profile { get; set; }
}

and parse original JSON text as

JsonBody json = JsonConvert.DeserializeObject<JsonBody>(jsonString);

Leave a Comment