Created
November 28, 2016 13:04
-
-
Save rlipscombe/b7008ba42bc5cec90a09dda8199d010c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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