Apparently, infinity and NaN are not a part of JSON specification, so this PHP code:
$numbers = array();
$numbers [\'positive_infinity\'] = +INF;
$numbers [\
According to JSON spec, there is no Infinity or NaN values: http://json.org/
Workarounds:
Reject using JSON (pure JSON), and write your own json_encode function, which will handle INF/NAN (converting to "Infinity" and "NaN" respectively), and make sure you are parsing JSON using something like result = eval('(' + json + ')');
on the client side.
Pre convert your IFN/NAN values into string values ('Infinity' and 'NaN'), and when you are going to operate with those values in JavaScript, use the following construction: var number1 = (+numbers.positive_infinity);
. This will convert string value 'Infinity' into numeric Infinity
representation.