mirror of https://github.com/rxi/json.lua.git
Fixed decoding of escaped '/', added test
parent
45cd518b25
commit
4fb28bbeee
2
json.lua
2
json.lua
|
@ -25,7 +25,7 @@ local escape_char_map = {
|
||||||
[ "\t" ] = "\\t",
|
[ "\t" ] = "\\t",
|
||||||
}
|
}
|
||||||
|
|
||||||
local escape_char_map_inv = {}
|
local escape_char_map_inv = { [ "\\/" ] = "/" }
|
||||||
for k, v in pairs(escape_char_map) do
|
for k, v in pairs(escape_char_map) do
|
||||||
escape_char_map_inv[v] = k
|
escape_char_map_inv[v] = k
|
||||||
end
|
end
|
||||||
|
|
|
@ -156,6 +156,7 @@ test("decode escape", function()
|
||||||
[ [["\r\n\t\\\""]] ] = '\r\n\t\\"',
|
[ [["\r\n\t\\\""]] ] = '\r\n\t\\"',
|
||||||
[ [["\\"]] ] = '\\',
|
[ [["\\"]] ] = '\\',
|
||||||
[ [["\\\\"]] ] = '\\\\',
|
[ [["\\\\"]] ] = '\\\\',
|
||||||
|
[ [["\/"]] ] = '/',
|
||||||
}
|
}
|
||||||
for k, v in pairs(t) do
|
for k, v in pairs(t) do
|
||||||
local res = json.decode(k)
|
local res = json.decode(k)
|
||||||
|
|
Loading…
Reference in New Issue