Created
June 14, 2013 06:26
-
-
Save nenjiru/5779863 to your computer and use it in GitHub Desktop.
オブジェクトをクエリーにする
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
/** | |
* オブジェクトをクエリーにする | |
* @param obj {Object} | |
* @returns {String} | |
* @private | |
*/ | |
toQuery = function(obj) | |
{ | |
var query = ''; | |
for (var name in obj) | |
{ | |
//ブレース[]含んでたら | |
if (decodeURIComponent(name).match(/\[\]/)) | |
{ | |
//配列にする | |
query += '&'+ name +'='+ obj[name].join('&'+name+'='); | |
} | |
else | |
{ | |
query += '&'+ name +'='+ obj[name]; | |
} | |
} | |
return query.replace('&', ''); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment