|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69255 Double to Int convertation while json encode-decode
Submitted: 2015-03-18 09:57 UTC Modified: 2015-03-18 21:21 UTC
From: oleksiy dot tykhonovskyy at agito dot pl Assigned:
Status: Not a bug Package: JSON related
PHP Version: 5.5.22 OS:
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:
Solve the problem:
35 + 6 = ?
Subscribe to this entry?

 [2015-03-18 09:57 UTC] oleksiy dot tykhonovskyy at agito dot pl
Double to Int convertation while json encode-decode in case number has .0 end... 

From manual page:

Test script:
php > $a = ['price' => 11.00];
php > var_dump($a);
array(1) {
  'price' =>
php > var_dump(json_decode(json_encode($a), true));
array(1) {
  'price' =>


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-03-18 21:21 UTC]
-Status: Open +Status: Not a bug
 [2015-03-18 21:21 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

The JSON specifications don't distinguish between integer and
floating point numbers (or other representations), therefore 11.0
and 11 are considered identical, so json_encode() chooses the
shortest representation.

However, there will be a new option to json_encode(), 

[1] <>
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Fri Feb 03 22:03:53 2023 UTC