Return a standard json format for arrays

This commit is contained in:
Alfredo Cardigliano 2020-05-29 12:47:22 +02:00
parent da44b8fb65
commit 6eec119083
8 changed files with 32 additions and 13 deletions

View file

@ -85,12 +85,11 @@ if counters == nil then
return
end
res.data = {}
for day=1,days do
local day_epoch = epoch_begin + ((day-1) * day_secs)
res.data[day_epoch] = {}
res[day_epoch] = {}
for hour=1,24 do
res.data[day_epoch][hour] = 0
res[day_epoch][hour] = 0
end
end
@ -99,7 +98,7 @@ local curr_epoch = epoch_begin
for k,v in ipairs(counters) do
local day_epoch = v.hour - (v.hour % day_secs)
local hour = (v.hour - day_epoch) / hour_secs
res.data[day_epoch][hour] = tonumber(v.count)
res[day_epoch][hour] = tonumber(v.count)
end -- for
print(rest_utils.rc(rc, res))