Skip to content

Commit 5b06fd9

Browse files
authored
fix json_encode for integer values
without the parameter JSON_NUMERIC_CHECK the json_encode function is ignoring the integer values from a array or database and then the integer values are serialized into a string.
1 parent 79c6ad2 commit 5b06fd9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

application/libraries/Format.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,14 +403,14 @@ public function to_json($data = NULL)
403403

404404
if (empty($callback) === TRUE)
405405
{
406-
return json_encode($data);
406+
return json_encode($data, JSON_NUMERIC_CHECK);
407407
}
408408

409409
// We only honour a jsonp callback which are valid javascript identifiers
410410
elseif (preg_match('/^[a-z_\$][a-z0-9\$_]*(\.[a-z_\$][a-z0-9\$_]*)*$/i', $callback))
411411
{
412412
// Return the data as encoded json with a callback
413-
return $callback.'('.json_encode($data).');';
413+
return $callback.'('.json_encode($data, JSON_NUMERIC_CHECK).');';
414414
}
415415

416416
// An invalid jsonp callback function provided.

0 commit comments

Comments
 (0)