const data = {
    title: '芋圆社区',
    type: '博客',
    url: 'www.inhami.com',
    logo: undefined,
    person: 200
}
const jsonText = JSON.stringify(data)
console.log(jsonText);
	
const data = {
    title: '芋圆社区',
    type: '博客',
    url: 'www.inhami.com',
    person: 200,
    logo: undefined,
}
// 我传了一个数组,jsonText只会包含数组中列出的对象属性
const jsonText = JSON.stringify(data, ['title', 'person'])
console.log(jsonText);
	
const data = {
    title: '芋圆社区',
    type: '博客',
    url: 'www.inhami.com',
    person: 200,
    logo: undefined,
}
const jsonText = JSON.stringify(data, (key, value) => {
    switch(key) {
        case 'type':
            return "社区";
        case 'url':
            return undefined;
        case 'person':
            return value + '人';
        default:
            return value;
    }
})
console.log(jsonText);
	
const data = {
    title: '芋圆社区',
    type: '博客',
    person: 200,
    logo: undefined,
}
console.log(JSON.stringify(data, null, 0));
console.log(JSON.stringify(data, null, 4));
	
const data = {
    title: '芋圆社区',
    type: '博客',
    person: 200,
    logo: undefined,
}
console.log(JSON.stringify(data, null, '%%%%%'));
// 因为最大缩进为10,所以10个'-'后的'$'就被截断了
console.log(JSON.stringify(data, null, '----------$$$$$$'));
	
const data = {
    title: '芋圆社区',
    type: '博客',
    person: 200,
    logo: undefined,
}
// 序列化
let jsonText = JSON.stringify(data);
// 解析
let data_2 = JSON.parse(jsonText)
console.log(data_2);
	
const data = {
    title: '芋圆社区',
    type: '博客',
    person: 200,
    logo: undefined,
}
// 序列化
let jsonText = JSON.stringify(data);
// 解析
let data_2 = JSON.parse(jsonText, (key, value) => key === 'title' ? 'Hey、小怪兽' : value)
console.log(data_2);
	
JSON.parse(data)
	
let data = null;
try {
    data = JSON.parse(jsonData)
} catch (error) {
    data = jsonData
}
	此页面不支持夜间模式!
已进入夜间模式!
已进入普通模式!
搜索框不允许为空
签到成功!经验+5!芋圆币+2!
签到失败!今日已签到!
需要登录社区账号才可以进入!