I have a dynamic object that looks like this,
{
\"2\" : \"foo\",
\"5\" : \"bar\",
\"8\" : \"foobar\"
}
How can I convert this
You can fill the dictionary using reflection:
public Dictionary Dyn2Dict(dynamic dynObj)
{
var dictionary = new Dictionary();
foreach (PropertyDescriptor propertyDescriptor in TypeDescriptor.GetProperties(dynObj))
{
object obj = propertyDescriptor.GetValue(dynObj);
dictionary.Add(propertyDescriptor.Name, obj);
}
return dictionary;
}