diff options
Diffstat (limited to 'src/utils.lua')
| -rw-r--r-- | src/utils.lua | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/utils.lua b/src/utils.lua index 83e1d46..5851e1c 100644 --- a/src/utils.lua +++ b/src/utils.lua @@ -27,3 +27,27 @@ function table.extracthex(response, start, last) return result end + +-- table -> pretty print +function table.dump(response) + + if type(response) == "table" then + + local start = "{ " + + for key, value in pairs(response) do + + if type(key) ~= "number" then key = '"' .. key .. '"' end + + start = start .. "[" .. key .. "] = " .. table.dump(value) .. "," + + end + + return start .. "} " + + else + + return tostring(response) + + end +end |
