为了账号安全,请及时绑定邮箱和手机立即绑定

javascript如何将一个个json数据合并成一个对象数组?

javascript如何将一个个json数据合并成一个对象数组?

如{"name":"`111","password":"111","title":"111","tag":"111","contents":"1111"},{"name":"222","password":"22","title":"22","tag":"22","contents":"222"},{"name":"11","password":"11","title":"11","tag":"11","contents":"11111"}转化为[{"name":"`111","password":"111","title":"111","tag":"111","contents":"1111"},{"name":"222","password":"22","title":"22","tag":"22","contents":"222"},{"name":"11","password":"11","title":"11","tag":"11","contents":"11111"}]补充一下,这是从后台传到前端的数据
查看完整描述

1 回答

?
慕标琳琳

TA贡献1830条经验 获得超9个赞

// 把数据往里面一扔

var tx = {

    a: {"name": "`111", "password": "111", "title": "111", "tag": "111", "contents": "1111"},

    b: {"name": "222", "password": "22", "title": "22", "tag": "22", "contents": "222"},

    c: {"name": "11", "password": "11", "title": "11", "tag": "11", "contents": "11111"}

};

var sb = [];

// 遍历栈入

for (var tb in tx) {

    sb.push(tx[tb])

}

console.log(sb[]);


查看完整回答
反对 回复 2018-12-13
  • 1 回答
  • 0 关注
  • 894 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信