JSON strictly limits the types of data that can be included inside its string structure.
This strictness ensures that JSON data can be decoded by any programming language safely!
In JSON, values must be one of the following exact data types:
{}.[].JSON values cannot be JavaScript-specific elements like a function, a date, or undefined.
If you attempt to stringify a function, it will either throw an error or be completely removed from the data.
To pass a date, you must first convert the date object into a standard string!
let jsonString = `
{
"name": "John", // String
"age": 30, // Number
"isStudent": false, // Boolean
"courses": ["Math", "IT"],// Array
"car": null // Null
}`;
let user = JSON.parse(jsonString);
console.log(user.courses[1]); // Outputs: IT
Which of the following is NOT a valid data type in JSON?