Bug #80484 [NEW]: json_encode() without converting string to float
From: teflontelefon at gmail dot com
Operating system: Linux
PHP version: Irrelevant
Package: *General Issues
Bug Type: Bug
Bug description:json_encode() without converting string to float
Description:
------------
json_encode() with JSON_NUMERIC_CHECK needs a way to encode strings as
numbers WITHOUT converting them to float first. You just can't use money
types and pass them with the built in json_encode() feature. I've looked
all over and there is no solution except to create my own json_encode()
which will bear performance issues compared to the built-in method.
Test script:
---------------
echo json_encode(['x'=>'0.00000001'], JSON_NUMERIC_CHECK)."\n";
Expected result:
----------------
{"x":0.00000001}
Actual result:
--------------
{"x":1.0e-8}
--
Edit bug report at https://bugs.php.net/bug.php?id=80484&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=80484&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=80484&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=80484&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=80484&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=80484&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=80484&r=support
Expected behavior: https://bugs.php.net/fix.php?id=80484&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=80484&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=80484&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=80484&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80484&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=80484&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=80484&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=80484&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=80484&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=80484&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=80484&r=mysqlcfg
Thread (4 messages)
- teflontelefon at gmail dot com