php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57819 json_encode outputs floats with commas instead of dots with certain locales
Submitted: 2007-09-01 17:05 UTC Modified: 2008-12-18 21:27 UTC
From: salo at laborint dot com Assigned:
Status: Closed Package: json (PECL)
PHP Version: 5.2.1 OS: Windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
24 + 15 = ?
Subscribe to this entry?

 
 [2007-09-01 17:05 UTC] salo at laborint dot com
Description:
------------
If you do setlocale("estonia") on a windows machine then json_encode outputs floats with commas which will cause a parse error in all browsers. It should output dots

Reproduce code:
---------------
setlocale("estonia");
json_encode(array('float_test'=>10.12345));

Expected result:
----------------
{"float_test": 10.12345}

Actual result:
--------------
{"float_test": 10,12345}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-12-21 09:05 UTC] jb at fragp dot com
Same problem here with setlocale("de"); and json_encode of a float.
 [2008-12-18 21:27 UTC] scottmac@php.net
This was fixed in 5.2.5.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Sep 19 15:01:30 2019 UTC