mirror of https://github.com/rxi/json.lua.git
compatibility with lua 5.1 (in lua 5.1 -> tostring(val, stack) returns tostring(val)..tostring(stack), but in lua>5.1 it returns just tostring(val).
parent
bee7ee3431
commit
e792cd0336
6
json.lua
6
json.lua
|
@ -111,13 +111,17 @@ local function encode_number(val)
|
||||||
return string.format("%.14g", val)
|
return string.format("%.14g", val)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function encode_bool(val)
|
||||||
|
return tostring(val)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
local type_func_map = {
|
local type_func_map = {
|
||||||
[ "nil" ] = encode_nil,
|
[ "nil" ] = encode_nil,
|
||||||
[ "table" ] = encode_table,
|
[ "table" ] = encode_table,
|
||||||
[ "string" ] = encode_string,
|
[ "string" ] = encode_string,
|
||||||
[ "number" ] = encode_number,
|
[ "number" ] = encode_number,
|
||||||
[ "boolean" ] = tostring,
|
[ "boolean" ] = encode_bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue