这是我的json有效载荷
"multiList": [
{
"Key": "my_key",
"Value": this is my key
},
{
"Key": "my_text_box",
"Value": "This is my text box"
},
如何使用jquery
动态转换它"multiList": [
{
"my_key" : "this is my key"
},
{
"my_text_box": "This is my text box"
},
答案 0 :(得分:0)
例如:
yourobj.multiList = yourobj.multiList.map(function(v) {
var r = {};
r[v.Key] = v.Value;
return r;
});
如果您想支持IE8,则必须use a shim for map或使用for
代替map
:
for (var i=0; i<yourobj.multiList.length; i++) {
var v = yourobj.multiList[i];
var r = {};
r[v.Key] = v.Value;
yourobj.multiList[i] = r;
}