Merge pull request #3133 from electron93/fix-comma

Fix comma on some locales when formatting float and double values
This commit is contained in:
mikeprimm 2020-09-22 12:43:54 -05:00 committed by GitHub
commit 56076f44ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,6 +4,7 @@ import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.List;
import java.util.Locale;
import java.util.Map;
public class Json {
@ -69,7 +70,7 @@ public class Json {
} else if (o instanceof Integer || o instanceof Long) {
s.append(o.toString());
} else if (o instanceof Float || o instanceof Double) {
s.append(String.format("%.2f",((Number)o).doubleValue()));
s.append(String.format(Locale.US, "%.2f",((Number)o).doubleValue()));
} else if (o instanceof Map<?, ?>) {
Map<?, ?> m = (Map<?, ?>) o;
s.append("{");