Skip to content

Instantly share code, notes, and snippets.

@hkongm
Created August 30, 2013 06:40
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 hkongm/6386886 to your computer and use it in GitHub Desktop.
Save hkongm/6386886 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