Hi,
The attached patch fixes the JSON generation when dealing with NaN (not
a number), this makes the JSON parsing in the web browser succeed
(before it would get a "nan" which is not a valid JS value)
Chris
write(" }")
end
elseif type(x) == "number" or type(x) == "boolean" then
- write(tostring(x))
+ if (x ~= x) then
+ -- NaN is the only value that doesn't equal to itself.
+ write("Number.NaN")
+ else
+ write(tostring(x))
+ end
elseif type(x) == "string" then
write("%q" % tostring(x))
end