Skip to content

Commit 95fd1b0

Browse files
Merge pull request chriskacerguis#669 from pberndro/patch-1
fix json_encode for integer values
2 parents 79c6ad2 + 5b06fd9 commit 95fd1b0

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)