Skip to content

Instantly share code, notes, and snippets.

@abhiomkar
Created July 7, 2011 17:43
Show Gist options
  • Save abhiomkar/1070079 to your computer and use it in GitHub Desktop.
Save abhiomkar/1070079 to your computer and use it in GitHub Desktop.
URL Query Parameter Parser in Javascript
// Author: Abhinay Omkar
// Input: "red=123&green=456&blue=789"
// Output: [{key: 'red', value: 123}, {key: 'green', value: 456}, ...
var dict = [], i = 0; qparams.split('&').map(function(s) { dict[i] = {}; kv = s.split('='); dict[i].key = kv[0]; dict[i].value = kv[1]; i = i + 1; })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment