Skip to content

Instantly share code, notes, and snippets.

@fordlee404
Created August 30, 2013 06:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fordlee404/6386769 to your computer and use it in GitHub Desktop.
Save fordlee404/6386769 to your computer and use it in GitHub Desktop.
function QueryStringToJSON() {
var pairs = location.search.slice(1).split('&');
var result = {};
pairs.forEach(function(pair) {
pair = pair.split('=');
result[pair[0]] = decodeURIComponent(pair[1] || '');
});
return JSON.parse(JSON.stringify(result));
}
var query_string = QueryStringToJSON();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment