JAVASCRIPT
change js to json
var obj = {name: "Martin", age: 30, country: "United States"};
var json = JSON.stringify(obj);
console.log(json);
"https://www.tutorialrepublic.com/faq/how-to-convert-js-object-to-json-string.php"
Converting JSON to JavaScript Object
const jsonData = '{ "name": "John", "age": 22 }';
const obj = JSON.parse(jsonData);
console.log(obj.name);
change js to json
var obj = {name: "Martin", age: 30, country: "United States"};
var json = JSON.stringify(obj);
console.log(json);
"https://www.tutorialrepublic.com/faq/how-to-convert-js-object-to-json-string.php"
Converting JavaScript Object to JSON
const jsonData = { "name": "John", "age": 22 };
const obj = JSON.stringify(jsonData);
console.log(obj);
Converting JSON to JavaScript Object
const jsonData = '{ "name": "John", "age": 22 }';
const obj = JSON.parse(jsonData);
console.log(obj.name);
Javascript object convert into JSON
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)
Converting JavaScript Object to JSON
const jsonData = { "name": "John", "age": 22 };
const obj = JSON.stringify(jsonData);
console.log(obj);
how to convert json to javascript object
Javascript object convert into JSON
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)
how to convert json to javascript object