格式化json对象
const list= {name: 'lisi',age: 14,id: 1}
JSON.stringify(list, null, " ")
格式化json字符串
let list= "{name: 'lisi',age: 14,id: 1}"
list = JSON.parse(list)
JSON.stringify(list, null, " ")
输出
{
name: 'lisi',
age: 14,
id: 1
}
const list= {name: 'lisi',age: 14,id: 1}
JSON.stringify(list, null, " ")
let list= "{name: 'lisi',age: 14,id: 1}"
list = JSON.parse(list)
JSON.stringify(list, null, " ")
{
name: 'lisi',
age: 14,
id: 1
}