Skip to content

Instantly share code, notes, and snippets.

@rlipscombe
Created November 28, 2016 13:04
Show Gist options
  • Select an option

  • Save rlipscombe/b7008ba42bc5cec90a09dda8199d010c to your computer and use it in GitHub Desktop.

Select an option

Save rlipscombe/b7008ba42bc5cec90a09dda8199d010c to your computer and use it in GitHub Desktop.
function dump(o) {
switch (typeof(o)) {
case "table":
local table = "";
foreach (k, v in o) {
if (table != "") {
table += ", "
}
table += dump(k) + ": " + dump(v);
}
return "{" + table + "}";
case "string":
return "'" + o + "'";
case "integer":
return o;
case "bool":
return o ? "true" : "false";
case "array":
local array = "";
foreach (v in o) {
if (array != "") {
array += ", ";
}
array += dump(v);
}
return "[" + array + "]";
default:
return typeof(o);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment