Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JsonSerializer does not respect Culture when deserializing primitive types #1606

Merged
merged 1 commit into from Jul 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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