|
|
@ -21,10 +21,12 @@ var stack = []; |
|
|
|
* @param obj {Variant} any arbitrary value to convert to query string |
|
|
|
* @param sep {String} (optional) Character that should join param k=v pairs together. Default: "&" |
|
|
|
* @param eq {String} (optional) Character that should join keys to their values. Default: "=" |
|
|
|
* @param munge {Boolean} (optional) Indicate whether array/object params should be munged, PHP/Rails-style. Default: true |
|
|
|
* @param name {String} (optional) Name of the current key, for handling children recursively. |
|
|
|
* @static |
|
|
|
*/ |
|
|
|
QueryString.stringify = function (obj, sep, eq, name) { |
|
|
|
QueryString.stringify = function (obj, sep, eq, munge, name) { |
|
|
|
munge = typeof(munge) == "undefined" ? true : munge; |
|
|
|
sep = sep || "&"; |
|
|
|
eq = eq || "="; |
|
|
|
if (isA(obj, null) || isA(obj, undefined) || typeof(obj) === 'function') { |
|
|
@ -37,9 +39,9 @@ QueryString.stringify = function (obj, sep, eq, name) { |
|
|
|
} |
|
|
|
if (isA(obj, [])) { |
|
|
|
var s = []; |
|
|
|
name = name+'[]'; |
|
|
|
name = name+(munge ? '[]' : ''); |
|
|
|
for (var i = 0, l = obj.length; i < l; i ++) { |
|
|
|
s.push( QueryString.stringify(obj[i], sep, eq, name) ); |
|
|
|
s.push( QueryString.stringify(obj[i], sep, eq, munge, name) ); |
|
|
|
} |
|
|
|
return s.join(sep); |
|
|
|
} |
|
|
@ -59,7 +61,7 @@ QueryString.stringify = function (obj, sep, eq, name) { |
|
|
|
for (var i = 0, l = keys.length; i < l; i++) { |
|
|
|
var key = keys[i]; |
|
|
|
var n = begin + key + end; |
|
|
|
s.push(QueryString.stringify(obj[key], sep, eq, n)); |
|
|
|
s.push(QueryString.stringify(obj[key], sep, eq, munge, n)); |
|
|
|
} |
|
|
|
|
|
|
|
stack.pop(); |
|
|
|