From: gebura at evilkittens dot org Operating system: Linux / Unix PHP version: 5.2.4 PHP Bug Type: JSON related Bug description: json_encode output numbers formated according the to locales instead of standar
Description: ------------ json_encode() output numbers formated according the to locales instead of standard format. For example, in french coma is used for separate decimals. (like 1,5) But in json: - numbers must use a point for separate decimals (like 1.5) - coma is used as field separator. (like "a","b") So the result is not correct. This bug is related with Bug #40360 ('current locale affects how json_encode encodes floats') witch is closed. Reproduce code: --------------- <?php if (setlocale(LC_ALL,"fr_FR.UTF-8") != "fr_FR.UTF-8") { die("Could not change the locale!"); } $foo = Array(100.10,"bar"); echo json_encode($foo); Class bar {} $bar1 = new bar; $bar1->a = 100.10; $bar1->b = "foo"; echo json_encode($bar1); ?> Expected result: ---------------- [100.1,"bar"]{"a":100.1,"b":"foo"} Actual result: -------------- [100,1,"bar"] // 2 fields => 3 fields {"a":100,1,"b":"foo"} // the output couldn't be evaluated -- Edit bug report at http://bugs.php.net/?id=42785&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=42785&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=42785&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=42785&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=42785&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=42785&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=42785&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=42785&r=needscript Try newer version: http://bugs.php.net/fix.php?id=42785&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=42785&r=support Expected behavior: http://bugs.php.net/fix.php?id=42785&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=42785&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=42785&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=42785&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=42785&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=42785&r=dst IIS Stability: http://bugs.php.net/fix.php?id=42785&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=42785&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=42785&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=42785&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=42785&r=mysqlcfg