xref: /PHP-8.0/ext/json/tests/bug41403.phpt (revision c5401854)
1--TEST--
2Bug #41403 (json_decode cannot decode floats if localeconv decimal_point is not '.')
3--SKIPIF--
4<?php
5if (setlocale(LC_NUMERIC, "de_DE") === false) {
6    die("skip no de_DE locale");
7}
8?>
9--INI--
10serialize_precision=-1
11--FILE--
12<?php
13
14setlocale(LC_NUMERIC, 'de_DE');
15var_dump(json_decode('[2.1]'));
16var_dump(json_decode('[0.15]'));
17var_dump(json_decode('[123.13452345]'));
18var_dump(json_decode('[123,13452345]'));
19
20echo "Done\n";
21?>
22--EXPECT--
23array(1) {
24  [0]=>
25  float(2.1)
26}
27array(1) {
28  [0]=>
29  float(0.15)
30}
31array(1) {
32  [0]=>
33  float(123.13452345)
34}
35array(2) {
36  [0]=>
37  int(123)
38  [1]=>
39  int(13452345)
40}
41Done
42