我有以下示例代码
var obj = { a: {b:1, c:3 }, d :{f:5}}
var string = "";
for(var key in obj){
for(var subkey in obj[key]){
string += subkey + "="+ obj[key][subkey] + "&";
//for last iteration "&" should not be added.
}
}
console.log(string);
输出是
b=1&c=3&f=5&
所需输出
b=1&c=3&f=5