Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 55ddcd9

Browse files
author
Discobanan
committed
Added InvariantCulture to ParseStringDelegate for numerics. We had an issue with xamarin/monodroid where negative numbers in parsed json-strings was returned as 0. This only happened on devices where language was set to something else than English. This commit fixes that problem.
1 parent 5b811ee commit 55ddcd9

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/ServiceStack.Text/Common/DeserializeBuiltin.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ private static ParseStringDelegate GetParseFn()
3434
if (typeof(T) == typeof(bool))
3535
return value => value.Length == 1 ? value == "1" : bool.Parse(value);
3636
if (typeof(T) == typeof(byte))
37-
return value => byte.Parse(value);
37+
return value => byte.Parse(value, CultureInfo.InvariantCulture);
3838
if (typeof(T) == typeof(sbyte))
39-
return value => sbyte.Parse(value);
39+
return value => sbyte.Parse(value, CultureInfo.InvariantCulture);
4040
if (typeof(T) == typeof(short))
41-
return value => short.Parse(value);
41+
return value => short.Parse(value, CultureInfo.InvariantCulture);
4242
if (typeof(T) == typeof(int))
43-
return value => int.Parse(value);
43+
return value => int.Parse(value, CultureInfo.InvariantCulture);
4444
if (typeof(T) == typeof(long))
45-
return value => long.Parse(value);
45+
return value => long.Parse(value, CultureInfo.InvariantCulture);
4646
if (typeof(T) == typeof(float))
4747
return value => float.Parse(value, CultureInfo.InvariantCulture);
4848
if (typeof(T) == typeof(double))

0 commit comments

Comments
 (0)