Converting a JSON Text to a JavaScript Object
In JavaScript, you can parse a JSON text into a JavaScript object using the JSON.parse()
method:
const jsonText = {
"name": "Raj",
"age": 30
}
const jsonObject = JSON.parse(jsonText);
console.log(jsonObject);
JavaScript Object:
{
"name": "Raj",
"age": 30
}
What is JSON
JSON, short for JavaScript Object Notation, is a lightweight data-interchange format used for transmitting and storing data. It has become a standard format for web-based APIs due to its simplicity and ease of use.