如何将json对象转成数组???json对象:{"phone_num_wxx":"用户手机号","phone_city_wxx":"手机号归属地","sex_wxx":"性别","income_wxx":"收入","age_wxx":"年龄"}希望转换成这样的数组形式:["phone_num_wxx","用户手机号","phone_city_wxx","手机号归属地","sex_wxx","性别","income_wxx","收入","age_wxx","年龄"]
1 回答
侃侃尔雅
TA贡献1801条经验 获得超16个赞
这个是你要的
[key,value,name,value, ...]
const list = []
Object.keys(json).forEach(function(item, index) {
this.push( item, json[item])
}, list)
但我想你要是循环渲染应该要这样好用些(需要就直接循环渲染就可以,对应的值就是key 和 value)
[{},{},{}]
const list = Object.keys(json).map((item, index) => ({key: item, value:json[item]}))
添加回答
举报
0/150
提交
取消