I have a JSON string that contains some key with the following value: 123.00. When I use json_decode function I get the decoded string where the previous key equal to 123, not to 123.00. Is there a way to correct decode such values without wrapping into quotes?
5 Answers
This is currently being brought up as a PHP bug:
Bug Report: https://bugs.php.net/bug.php?id=50224
In the future, there may be functionality to pass a flag through the options parameter for stricter typing. For now, however, wrapping it in quotes will have to suffice.
3 Comments
Ihor Timoshenko
Thank you for your response and for the link!
Sverrir Sigmundarson
Fixed as of PHP 7.0, new option available for json_decode,
JSON_PRESERVE_FRACTIONAL_PARTBjørn Lindner
I believe it should be
JSON_PRESERVE_ZERO_FRACTION. See respective commit