mirror of https://github.com/rxi/json.lua.git
Update json.lua
add a dummy key { _ = false } to force empty table to be encoded to as an objectpull/40/head
parent
dbf4b2dd2e
commit
c2aad59ba6
4
json.lua
4
json.lua
|
@ -90,7 +90,9 @@ local function encode_table(val, stack)
|
||||||
if type(k) ~= "string" then
|
if type(k) ~= "string" then
|
||||||
error("invalid table: mixed or invalid key types")
|
error("invalid table: mixed or invalid key types")
|
||||||
end
|
end
|
||||||
table.insert(res, encode(k, stack) .. ":" .. encode(v, stack))
|
if k ~= "_" then
|
||||||
|
table.insert(res, encode(k, stack) .. ":" .. encode(v, stack))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
stack[val] = nil
|
stack[val] = nil
|
||||||
return "{" .. table.concat(res, ",") .. "}"
|
return "{" .. table.concat(res, ",") .. "}"
|
||||||
|
|
Loading…
Reference in New Issue