Skip to content

Commit

Permalink
Added config option for how to handle empty tables by default
Browse files Browse the repository at this point in the history
  • Loading branch information
DorianGray committed Mar 21, 2014
1 parent 9aeb6e8 commit 1a79af5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/output/json.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ return {
output = meta.__toView(output, context)
end

context.response.send(json.encode(output))
local raw
if config.encodeEmptyTableAsArray and next(output) == nil then
raw = "[]"
else
raw = json.encode(output)
end

context.response.send(raw)
end,

options = {
Expand Down

0 comments on commit 1a79af5

Please sign in to comment.