一.对象转字符串 JSON.stringify()
const obj = {
id: 1,
name: 'jessie-xian',
age: 18
}
const objToStr = JSON.stringify(obj)
console.log('obj:', obj)
console.log('objToStr:', objToStr)
二.字符串转对象 JSON.parse()
const str = '{"id":1,"name":"jessie-xian","age":18}'
const strToObj = JSON.parse(str)
console.log('str:', str)
console.log('strToObj:', strToObj)