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"}]

补充一下,这是从后台传到前端的数据


慕尼黑的夜晚无繁华
浏览 898回答 1
1回答

慕标琳琳

// 把数据往里面一扔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[]);
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript