summaryrefslogtreecommitdiffhomepage
path: root/libs/web/luasrc
diff options
context:
space:
mode:
Diffstat (limited to 'libs/web/luasrc')
-rw-r--r--libs/web/luasrc/http.lua7
1 files changed, 6 insertions, 1 deletions
diff --git a/libs/web/luasrc/http.lua b/libs/web/luasrc/http.lua
index 8585405484..60a3e07228 100644
--- a/libs/web/luasrc/http.lua
+++ b/libs/web/luasrc/http.lua
@@ -333,7 +333,12 @@ function write_json(x)
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