Skip to content

Instantly share code, notes, and snippets.

@alexpchin
Created December 14, 2015 14:35
Show Gist options
  • Save alexpchin/e85eb2fe8503cf327b09 to your computer and use it in GitHub Desktop.
Save alexpchin/e85eb2fe8503cf327b09 to your computer and use it in GitHub Desktop.
Serialize Javascript
function serialize(obj) {
var str = [];
for(var p in obj)
if (obj.hasOwnProperty(p)) {
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
}
return str.join("&");
}
module.exports = serialize;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment