📌  相关文章
📜  将对象转换为 json javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:42.409000             🧑  作者: Mango

代码示例4
const person = {
    name: 'labib',
    age: 22,
    job: 'web-developer',
    frieds: ['ahsik', 'abir', 'alvi', 'hanafi'],
    childList: {
        firstChild: 'Salman',
        secondChild: 'Rafi',
        thirdChild: 'Anfi'
    }
}
const convertJson = JSON.stringify(person)
console.log(convertJson)
//Expected output:
/*
{"name":"labib","age":22,"job":"web-developer","frieds":["ahsik","abir","alvi","hanafi"],"childList":{"firstChild":"Salman","secondChild":"Rafi","thirdChild":"Anfi"}}
 */