forked from Dependencies/lua-json
Fixed parse_keyword() from making null -> false
parent
8b9c820218
commit
157fa12fae
8
json.lua
8
json.lua
|
@ -125,6 +125,12 @@ local delim_chars = create_set(" ", "\t", "\r", "\n", "]", "}", ",")
|
||||||
local escape_chars = create_set("\\", "/", '"', "b", "f", "n", "r", "t", "u")
|
local escape_chars = create_set("\\", "/", '"', "b", "f", "n", "r", "t", "u")
|
||||||
local keywords = create_set("true", "false", "null")
|
local keywords = create_set("true", "false", "null")
|
||||||
|
|
||||||
|
local keyword_map = {
|
||||||
|
[ "true" ] = true,
|
||||||
|
[ "false" ] = false,
|
||||||
|
[ "null" ] = nil,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
local function next_char(str, idx, set, negate)
|
local function next_char(str, idx, set, negate)
|
||||||
for i = idx, #str do
|
for i = idx, #str do
|
||||||
|
@ -216,7 +222,7 @@ local function parse_keyword(str, i, chr)
|
||||||
if not keywords[word] then
|
if not keywords[word] then
|
||||||
decode_error(str, i, "invalid keyword '" .. word .. "'")
|
decode_error(str, i, "invalid keyword '" .. word .. "'")
|
||||||
end
|
end
|
||||||
return (chr == "t") and true or (chr == "f") and false, x
|
return keyword_map[word], x
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue