Created
October 12, 2014 18:28
-
-
Save bogdanbiv/315c11e8f764f16c4552 to your computer and use it in GitHub Desktop.
Serialize object keys and values except values that are arrays or other objects. This is to be used in case JSON.stringify fails due to cyclic...
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 mystringify(input) { | |
var key, type, retVal = ""; | |
for(key in input) { | |
if (input.hasOwnProperty(key)) { | |
type = typeof(input[key]); | |
if (type === 'array' || type === 'object') { | |
retVal += key + ": " + type + ", "; | |
} else { | |
retVal += key + ": " + input[key] + ", "; | |
} | |
} | |
} | |
return retVal; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment