I have a dictionary
Dictionary<string, object> dict;
And i get values from it by typing
string foo = dict["foo"].ToString();
The dictionary is a serialized JSON result.
serializer.Deserialize<Dictionary<string, object>>(HttpContext.Current.Request["JSON"]);
What i would like to know if thers a way to convert it to an object, so i can type something like:
string foo = dict.foo;
Thanks
If you don’t know the exact members of the dictionary you can use
dynamicto get a pretty syntax as shown below. However, if you know the members of the dictionary and the types, then you could create your own class and do the conversion yourself. There might exists a framework to do that automatically.