Skip to content

Commit

Permalink
empty_as_json flag, 0.5-0
Browse files Browse the repository at this point in the history
  • Loading branch information
DorianGray committed Feb 20, 2017
1 parent 0ff1c36 commit fb7c32c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lusty-json-0.4-0.rockspec → lusty-json-0.5-0.rockspec
Original file line number Diff line number Diff line change
@@ -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.",
Expand Down
5 changes: 5 additions & 0 deletions lusty-json/output/json.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down

0 comments on commit fb7c32c

Please sign in to comment.