Skip to content

Commit b28e7f8

Browse files
committed
added support for deserializing a dictionary's values to a list
1 parent 4f90124 commit b28e7f8

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

RestSharp/Deserializers/JsonDeserializer.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,18 @@ private IDictionary BuildDictionary(Type type, object parent)
100100
foreach (var child in (IDictionary<string, object>)parent)
101101
{
102102
var key = child.Key;
103-
var item = ConvertValue(valueType, child.Value);
103+
object item;
104+
if(valueType.GetGenericTypeDefinition() != typeof(List<>))
105+
{
106+
var item = ConvertValue(valueType, child.Value);
107+
}
108+
else
109+
{
110+
foreach (var element in (JsonArray)child.Value)
111+
{
112+
var item = ConvertValue(valueType, element);
113+
}
114+
}
104115
dict.Add(key, item);
105116
}
106117

0 commit comments

Comments
 (0)