0

I got json like

{
    "Date": "22.10.10",
    "Date2": "22.10.10",
    "Levels": {
        "Simple": {
            "ID": "1",
            "NumCode": "2 SS",
            "Nominal": 1
        },
         "Harder": {
            "ID": "2",
            "NumCode": "2D tt",
            "Nominal": 43

        },
        "Crazy": {
            "ID": "3",
            "NumCode": "392 GG",
            "Nominal": 100
        }
    }
}

How can i parse it using c# and Newtonsoft. I can have unlimited quantity of Levels. And i dont know all names

  • Does this answer your question? [How to parse my json string in C#(4.0)using Newtonsoft.Json package?](https://stackoverflow.com/questions/13839865/how-to-parse-my-json-string-in-c4-0using-newtonsoft-json-package) – Dortimer Jan 03 '20 at 18:44
  • 4
    You can define `Levels` as a `Dictionary` where `SomeType` is a type with `ID`, `NumCode` and `Nominal` properties. – JLRishe Jan 03 '20 at 18:47
  • As mentioned above you can deserialize `Levels` into a `Dictionary` as shown in [Deserializing JSON when key values are unknown](https://stackoverflow.com/a/24901245/3744182) or [Deserializing JSON with unknown object names](https://stackoverflow.com/q/38688570/3744182) or [Parsing JSON Object with variable properties into strongly typed object](https://stackoverflow.com/q/34202496/3744182). – dbc Jan 03 '20 at 18:51

0 Answers0