diff --git a/src/LitJson/JsonMapper.cs b/src/LitJson/JsonMapper.cs index 9a7df3e..629963e 100644 --- a/src/LitJson/JsonMapper.cs +++ b/src/LitJson/JsonMapper.cs @@ -473,9 +473,24 @@ private static object ReadValue (Type inst_type, JsonReader reader) } } + object cvtVal = null; + Type[] arguments = value_type.GetGenericArguments(); + Type keyType = arguments[0]; + Type valType = arguments[1]; + try + { + cvtVal = Convert.ChangeType(property, keyType); + } + catch (Exception ex) + { + throw new JsonException(String.Format( + "The key '{0}' can not convert to " + + " value {1}", + property, keyType)); + } ((IDictionary) instance).Add ( - property, ReadValue ( - t_data.ElementType, reader)); + cvtVal, ReadValue ( + valType, reader)); } }