Deserializing JSON with unknown object names

It looks like you should be able to just get rid of your Measures class. Instead, put the dictionary straight into your Body class:

public class Body
{
    public string _id { get; set; }
    public Place place { get; set; }
    public int mark { get; set; }
    public Dictionary<string, SingleModule> measures { get; set; }
    public string[] modules { get; set; }
}

As a separate matter, I’d strongly recommend following .NET naming conventions for your properties, and using [JsonProperty("measures")] etc to indicate to Json.NET how to translate your properties into JSON.

Leave a Comment