Deserialize JSON to list with unknown object name in C#

3941 views c#

I want to deserialize following JSON.
The problem is that the objects "ANDE" & "DAR" can change.
Means the objects are unknown and change depending on the JSON i wanna deserialize.


How can i deserialize this kind of JSON with unknown objects in C#? Any help is highly appreciated.

answered question

If you known each different pattern use a TypeConverter

1 Answer


Then you should use a dynamic variable:

dynamic ReturnValue = JsonConvert.DeserializeObject(jsonstring);

note that as in dynamic objects, properties are determined after being assigned in runtime, so you will not get a drop down menu in design time, and also as its properties are unknown in design time, and property you test in design time even if its not correct, you wont get an error, and you will get the error in runtime when it is assigned.

posted this

Have an answer?


Please login first before posting an answer.