-1

I want to build a dynamic class with a given JSON. Atm i parse the json with

dynamic customConfig = JsonConvert.DeserializeObject(configJson); 

and its working fine with other json then the given BUT my problem is that the names of the properties (here valueOne and valueTwo are "dynamic", i get always others)

i Know if i know the names i can get e.g. the description by customConfig.config.valueOne.description But what can i do to get e.g. the description by dont have the name of valueOne?

configJson=
"config": {
        "valueOne":{
                "description": "My first example value.",
                "defaultValue": "Example 1",
                                "isRequired":false
               },
        "valueTwo":{
                "description": "My second example value.",
                "defaultValue": "Example 2",
                                "isRequired":false
                   },

         },

What i tried was to get it in a loop but i dont get it to another class.

            foreach (var param in customConfig.config)
            {
                foreach (var item in param)
                {
                  Config.config.description[i] = item.description;
                }
             i++;
            }

item.description gets the right description but why i cant save it in the other class (which is also dynamic)?

4

3 に答える 3