Javascript 如何在JSON数据中输入名称
我想将上面的json数据更改为下面的json数据表单Javascript 如何在JSON数据中输入名称,javascript,json,Javascript,Json,我想将上面的json数据更改为下面的json数据表单 [ { "key": 14, "pid": "test3", "name": "test3", "gender": "other", "age": 3, "birth_date": "2020-08-03
[
{
"key": 14,
"pid": "test3",
"name": "test3",
"gender": "other",
"age": 3,
"birth_date": "2020-08-03",
"regi_date": "2020-08-30T13:47:36.025570Z",
"fundus": "no image",
"status": "ready",
"del_yn": "no",
"del_date": null
},
{
"key": 13,
"pid": "test4",
"name": "test4",
"gender": "male",
"age": 4,
"birth_date": "2020-08-04",
"regi_date": "2020-08-30T13:47:16.174702Z",
"fundus": "no image",
"status": "ready",
"del_yn": "no",
"del_date": null
}
]
当console.log(JSON.stringify(originData,null,2))时代码>执行时,它将显示如下图所示
如何在json数据中添加标题?试试看-
"test": [
{
"key": 14,
"pid": "test3",
"name": "test3",
"gender": "other",
"age": 3,
"birth_date": "2020-08-03",
"regi_date": "2020-08-30T13:47:36.025570Z",
"fundus": "no image",
"status": "ready",
"del_yn": "no",
"del_date": null
},
{
"key": 13,
"pid": "test4",
"name": "test4",
"gender": "male",
"age": 4,
"birth_date": "2020-08-04",
"regi_date": "2020-08-30T13:47:16.174702Z",
"fundus": "no image",
"status": "ready",
"del_yn": "no",
"del_date": null
}
]
尝试console.log(JSON.stringify({test:originData},null,2))
JSON.stringify({test: originData}, null, 2)