Soapbox / laravel-formatter

A Formatter Class for Laravel 4 based on FuelPHP's Formatter Class
249 stars 95 forks source link

json_encode issue with PHP 5.3 #9

Closed sburkett closed 10 years ago

sburkett commented 10 years ago

When you have a string value such as "12E389532" (a serial number in my case), json_encode tries to encode it as a number (because it sees the "E" in it and thinks it is in scientific notation). Because of the JSON_NUMERIC_CHECK flag that is set in Formatter, it chokes.

Would recommend removing it for PHP 5.3 or lower, and for PHP 5.4 or higher, perhaps this would be better:

return $pretty ? static::pretty_json($data) : json_encode($data, JSON_NUMERIC_CHECK | JSON_BIGINT_AS_STRING);
grahammccarthy commented 10 years ago

Sorry about that. i have removed the check altogether.