Deserialize JSON with variable property names

26 views
0

I would like to desierialze the json from here.

Similar to this:

{
"BW": {
    "Neujahrstag": {
        "datum": "2017-01-01",
        "hinweis": ""
    },
    "Heilige Drei Ku00f6nige": {
        "datum": "2017-01-06",
        "hinweis": ""
    },
    "Gru00fcndonnerstag": {
        "datum": "2017-04-13",
        "hinweis": "Gemu00e4u00df u00a7 4 Abs. 3 des Feiertagsgesetzes von Baden-Wu00fcrttemberg[10] haben Schu00fcler am Gru00fcndonnerstag und am Reformationstag schulfrei. In der Regel legt das Kultusministerium die Ferientermine so fest, dass diese beiden Tage in die Osterferien bzw. in die Herbstferien fallen."
    },
    "Karfreitag": {
        "datum": "2017-04-14",
        "hinweis": ""
    }
},
"BY": {
    "Neujahrstag": {
        "datum": "2017-01-01",
        "hinweis": ""
    },
    "Heilige Drei Ku00f6nige": {
        "datum": "2017-01-06",
        "hinweis": ""
    }
}

}

I would like to deserialize into this:

public class Root
{
    public State[] States { get; set; }
}

public class State
{        
    public Holiday[] Holidays { get; set; }
}

public class Holiday
{
    public DateTime Date { get; set; }
    public string Note { get; set; }
}

But since the propertynames are not fixed I am not able to do this.

I’ve also tried using JObject.Parse() but that did not help me alot.

Any idea on how to do this ?