如图中的一个json对象:[ { "Id":"3972679ef2c04151972b376dd88e6413", "T_CourseId":"7a4494aae1804d3e94094583249750fe", "CourseName":"英语", "Code":"english" }, { "Id":"5665d803e7994b26a56c6287d12c2090", "T_CourseId":"75761ad2ce23498c9f9db134ab844aec", "CourseName":"药物化学", "Code":"ywhx" }]怎么使用js高效的将其中的CourseName更改为title,得到结果如下:[ { "Id":"3972679ef2c04151972b376dd88e6413", "T_CourseId":"7a4494aae1804d3e94094583249750fe", "title":"英语", "Code":"english" }, { "Id":"5665d803e7994b26a56c6287d12c2090", "T_CourseId":"75761ad2ce23498c9f9db134ab844aec", "title":"药物化学", "Code":"ywhx" }]
1 回答
炎炎设计
TA贡献1808条经验 获得超4个赞
var aaa = [
{
"Id":"3972679ef2c04151972b376dd88e6413",
"T_CourseId":"7a4494aae1804d3e94094583249750fe",
"CourseName":"英语",
"Code":"english"
},
{
"Id":"5665d803e7994b26a56c6287d12c2090",
"T_CourseId":"75761ad2ce23498c9f9db134ab844aec",
"CourseName":"药物化学",
"Code":"ywhx"
}
]
var bbb= JSON.parse(JSON.stringify(aaa).replace(/CourseName/g,"title"));
console.log(bbb)
添加回答
举报
0/150
提交
取消