diff --git a/lusty-json-0.4-0.rockspec b/lusty-json-0.5-0.rockspec similarity index 83% rename from lusty-json-0.4-0.rockspec rename to lusty-json-0.5-0.rockspec index 406d593..5e281dd 100644 --- a/lusty-json-0.4-0.rockspec +++ b/lusty-json-0.5-0.rockspec @@ -1,8 +1,8 @@ package = "lusty-json" -version = "0.4-0" +version = "0.5-0" source = { - url = "https://github.com/Olivine-Labs/lusty-json/archive/v0.4.tar.gz", - dir = "lusty-json-0.4" + url = "https://github.com/Olivine-Labs/lusty-json/archive/v0.5.tar.gz", + dir = "lusty-json-0.5" } description = { summary = "json input and output for lusty.", diff --git a/lusty-json/output/json.lua b/lusty-json/output/json.lua index 3a1bba1..a1371aa 100644 --- a/lusty-json/output/json.lua +++ b/lusty-json/output/json.lua @@ -3,6 +3,11 @@ local json = config.json return { handler = function(context) context.response.headers["content-type"] = "application/json" + if config.empty_as_array then + if type(context.output) == 'table' and next(context.output) == nil then + return context.response.send('[]') + end + end context.response.send(json.encode(context.output)) end,