Apparently, infinity and NaN are not a part of JSON specification, so this PHP code:
$numbers = array();
$numbers [\'positive_infinity\'] = +INF;
$numbers [\
As an update to readers of this question for newer versions of PHP >= 5.5.0, to get INF or NAN values from json_encode to be encoded as 0 rather than json_encode failing to output at all, add the JSON_PARTIAL_OUTPUT_ON_ERROR option.
As an example: json_encode($data, JSON_NUMERIC_CHECK | JSON_PARTIAL_OUTPUT_ON_ERROR);