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
2
json.lua
2
json.lua
|
@ -90,8 +90,10 @@ 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
|
||||||
|
if k ~= "_" then
|
||||||
table.insert(res, encode(k, stack) .. ":" .. encode(v, stack))
|
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, ",") .. "}"
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue