Skip to content

Instantly share code, notes, and snippets.

@c9n
Created March 11, 2014 09:03
Show Gist options
  • Save c9n/9482027 to your computer and use it in GitHub Desktop.
Save c9n/9482027 to your computer and use it in GitHub Desktop.
Query string to json
'use strict';
var list = location.search.substring(1).split('&');
var map = {};
for (var i = 0; i < list.length; i++) {
var kv = list[i].split('=');
map[kv[0]] = decodeURIComponent(kv[1]);
}
console.log(JSON.stringify(map));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment