More thorough escaping for JSON control chars

This commit is contained in:
Aaron Suen 2021-09-10 08:19:20 -04:00
parent 4f6575a987
commit 0cbcea29dd

View File

@ -37,7 +37,9 @@ ser["number"] = function(x)
end
ser["boolean"] = ser["number"]
ser["string"] = function(x)
return string_gsub(string_format("%q", x), "\n", "n")
return string_gsub(string_format("%q", x), "%c", function(c)
return "\\00" .. string_format("%02x", string_byte(c))
end)
end
ser["table"] = function(x)
local arr = {}