Skip to content

Commit 8fc4805

Browse files
AlejandroPAlejandro Panizza Carve
andauthored
- Fix numeric format in Json Serialization for locales where the comma is the decimal separator. (#1153)
Co-authored-by: Alejandro Panizza Carve <a.panizza@globant.com>
1 parent a65721e commit 8fc4805

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

dotnet/src/dotnetframework/GxClasses/Domain/GxCollections.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3161,18 +3161,20 @@ public override void Write(Utf8JsonWriter writer, bool value, JsonSerializerOpti
31613161
writer.WriteBooleanValue(value);
31623162
}
31633163
}
3164+
31643165
public class StringConverter : JsonConverter<string>
31653166
{
31663167
public override string Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
31673168
{
31683169
if (reader.TokenType == JsonTokenType.Number)
31693170
{
3171+
var numberFmt = CultureInfo.InvariantCulture.NumberFormat;
3172+
31703173
if (reader.TryGetInt32(out int l))
3171-
return l.ToString();
3172-
else if (reader.TryGetDecimal(out decimal d))
3173-
return d.ToString();
3174-
else
3175-
return reader.GetDouble().ToString();
3174+
return l.ToString(numberFmt);
3175+
if (reader.TryGetDecimal(out decimal d))
3176+
return d.ToString(numberFmt);
3177+
return reader.GetDouble().ToString(numberFmt);
31763178
}
31773179
return reader.GetString();
31783180
}

0 commit comments

Comments
 (0)