Skip to content

Instantly share code, notes, and snippets.

@h2rd
Created November 25, 2012 13:32
Show Gist options
  • Select an option

  • Save h2rd/4143502 to your computer and use it in GitHub Desktop.

Select an option

Save h2rd/4143502 to your computer and use it in GitHub Desktop.
make GET query string from object
exports.serialize = function (obj) {
var str = [];
for (var p in obj) {
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
}
return str.join("&");
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment