- var_dump: documentation ( source)
- json_decode: documentation ( source)
- preg_replace: documentation ( source)
<?php
function noBigInt($json) {
$max_int_length = strlen((string) PHP_INT_MAX) - 1;
return preg_replace('/:\s*(-?\d{'.$max_int_length.',})/', ': "$1"', $json);
}
$json = '{"string":"3 Little Pigs"}';
var_dump(json_decode(noBigInt($json),JSON_NUMERIC_CHECK));