Last active
August 29, 2015 14:26
-
-
Save HZ-labs/f92661acb952388f9182 to your computer and use it in GitHub Desktop.
This file contains 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
function toStringUrl(obj,parent) { | |
"use strict"; | |
var url,el,param,k; | |
parent = parent || ''; | |
url = []; | |
for (k in obj) { | |
el = obj[k]; | |
param = k; | |
if (parent !== '') { | |
param = parent + '[' + k + ']' | |
} | |
if (typeof el !== "object") { | |
url.push(param + '=' + el); | |
} else { | |
url.push(toStringUrl(el,param)); | |
} | |
} | |
return url.join('&'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment