var person={"first_name":"Tony","last_name":"Hawk","age":31};
var personJSONString=JSON.stringify(person);
// JavaScript object
const jsonData = { "name": "John", "age": 22 };
// converting to JSON
const obj = JSON.stringify(jsonData);
// accessing the data
console.log(obj); // "{"name":"John","age":22}"
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"}}
*/