请小伙伴帮忙,关于数据格式转换的问题
var page_data = [{
"student": {
"user_id": "278842",
"user_realanme": "阅卷学生46",
"student_no": "210512046",
"cm_id": "9758",
"cm_name": "初一(22)班"
},
"exam": [{
"ze_id": "477",
"zs_id": "1754",
"ze_xueke_name": "语文",
"ze_xueke": "1",
"yxcjd_score_xs": "78.0",
"yxcjd_grade_sort": "2",
"yxcjd_cm_sort": "1"
}, {
"ze_id": "495",
"zs_id": "1768",
"ze_xueke_name": "数学",
"ze_xueke": "2",
"yxcjd_score_xs": "",
"yxcjd_grade_sort": "",
"yxcjd_cm_sort": ""
}, {
"ze_id": "483",
"zs_id": "1758",
"ze_xueke_name": "英语",
"ze_xueke": "3",
"yxcjd_score_xs": "51.0",
"yxcjd_grade_sort": "2",
"yxcjd_cm_sort": "1"
}]
}, {
"student": {
"user_id": "278802",
"user_realanme": "骆海亮",
"student_no": "210512006",
"cm_id": "9757",
"cm_name": "初一(21)班"
},
"exam": [{
"ze_id": "477",
"zs_id": "1754",
"ze_xueke_name": "语文",
"ze_xueke": "1",
"yxcjd_score_xs": "84.0",
"yxcjd_grade_sort": "1",
"yxcjd_cm_sort": "1"
}, {
"ze_id": "495",
"zs_id": "1768",
"ze_xueke_name": "数学",
"ze_xueke": "2",
"yxcjd_score_xs": "",
"yxcjd_grade_sort": "",
"yxcjd_cm_sort": ""
}, {
"ze_id": "483",
"zs_id": "1758",
"ze_xueke_name": "英语",
"ze_xueke": "3",
"yxcjd_score_xs": "56.0",
"yxcjd_grade_sort": "1",
"yxcjd_cm_sort": "1"
}]
}]
变成下面的格式 变成以学科为主的
var two= [{
name: '语文',
children: [
{ yxcjd_score_xs: 78, yxcjd_cm_sort: 1, yxcjd_grade_sort: 2 },
{ yxcjd_score_xs: 84, yxcjd_cm_sort: 1, yxcjd_grade_sort: 1 },
]
},
{
name: '数学',
children: [
{ yxcjd_score_xs: 78, yxcjd_cm_sort: 1, yxcjd_grade_sort: 2 },
{ yxcjd_score_xs: 84, yxcjd_cm_sort: 1, yxcjd_grade_sort: 1 },
]
},
{
name: '英语',
children: [
{ yxcjd_score_xs: 78, yxcjd_cm_sort: 1, yxcjd_grade_sort: 2 },
{ yxcjd_score_xs: 84, yxcjd_cm_sort: 1, yxcjd_grade_sort: 1 },
]
},
]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
土办法, 坐等其它处理方式