Body
if (_.isArray(a)){
return _.flatten(_.map(a,function(item){
if (_.isArray(item)){
if (_.size(item) > 1){
return _.map(_.drop(item,1),function(inner){
return item[0] + '=' + inner;
});
} else if (_.size(item) == 1){
return [item[0] + '='];
} else {
return [];
}
} else if (_.isObject(item)){
var cand = _.find(formKeyCandidates,function(fkc){
return fkc[0] in item && fkc[1] in item;
});
var keyOnlyCand = _.find(formKeyCandidates,function(fkc){
return fkc[0] in item;
});
if (cand !== undefined){
return [item[cand[0]] + '=' + item[cand[1]]];
} else if (keyOnlyCand !== undefined){
return [item[keyOnlyCand[0]] + '='];
} else {
return [];
}
} else if (_.isString(item)){
return [item + '='] //TODO
} else {
return [];
}
})).join('&');
} else if (_.isObject(a)){
return _.map(Object.keys(a),function(k){
return k + '=' + (a[k]).toString();
}).join('&');
} else {
return undefined;
}