Created
July 17, 2014 18:07
-
-
Save darbicus/3c2a1a83851cbf301f60 to your computer and use it in GitHub Desktop.
serialize javascript objects for get http requests that submit data
This file contains 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 cerealize(object) { | |
return Object.getOwnPropertyNames(object) | |
.filter(function (e) { | |
return typeof object[e] !== 'function' && object[e].toString | |
}) | |
.map(function (n) { | |
return encodeURIComponent(n) + "=" + encodeURIComponent(object[n]); | |
}) | |
.join("&") | |
} | |
cerealize(Math); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment