Created
July 7, 2011 17:43
-
-
Save abhiomkar/1070079 to your computer and use it in GitHub Desktop.
URL Query Parameter Parser in Javascript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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