Skip to content

Commit

Permalink
Fixed JsonSerializer respects set Culture when deserializing primitiv…
Browse files Browse the repository at this point in the history
…e type (#1606)

Co-authored-by: Jiri Muller <george6279@seznam.cz>
  • Loading branch information
Georgiks and Jiri Muller committed Jul 15, 2021
1 parent c544837 commit 80e23bc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/RestSharp/Extensions/ReflectionExtensions.cs
Expand Up @@ -62,6 +62,8 @@ public static bool IsSubclassOfRawGeneric(this Type toCheck, Type generic)
return false;
}

internal static object ChangeType(this object source, Type newType, IFormatProvider provider) => Convert.ChangeType(source, newType, provider);

internal static object ChangeType(this object source, Type newType) => Convert.ChangeType(source, newType);

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/RestSharp/Serializers/Json/JsonSerializer.cs
Expand Up @@ -236,7 +236,7 @@ object ConvertValue(TypeInfo typeInfo, object value)
}

var type = typeInfo.AsType();
if (typeInfo.IsPrimitive) return value.ChangeType(type);
if (typeInfo.IsPrimitive) return value.ChangeType(type, Culture);

if (typeInfo.IsEnum) return type.FindEnumValue(stringValue, Culture);

Expand Down

0 comments on commit 80e23bc

Please sign in to comment.