-
-
Save nancystodd/2113582c1cf22a08d7e21f565bc310f1 to your computer and use it in GitHub Desktop.
Converts a ServiceNow glide record into a JSON string.
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 stringifyGr(record) { | |
| var result = ["{"]; | |
| var multiline = false; | |
| for (var key in record) { | |
| if(record.hasOwnProperty(key)) { | |
| var value = record[key].toString(); | |
| switch (typeof value) { | |
| case "undefined": | |
| case "function": | |
| case "unknown": | |
| break; | |
| default: | |
| if (multiline) { | |
| result.push(','); | |
| } | |
| result.push( | |
| JSON.stringify(key), | |
| ':', | |
| value === null ? "null" : JSON.stringify(value) | |
| ); | |
| multiline = true; | |
| break; | |
| } | |
| } | |
| } | |
| result.push("}"); | |
| return result.join(""); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment