Q: The JSON() method's characteristic is
-
A
It can be invoked manually as object.JSON()
-
B
It will be automatically invoked by the compiler
-
C
It is invoked automatically by the JSON.stringify() method
-
D
It cannot be invoked in any form
C
Answer:
C
Explanation:
JSON (JavaScript Object Notation) is a lightweight data interchange format that is easy for humans to read and write and easy for machines to parse and generate. It is based on a subset of the JavaScript programming language, and it is commonly used to transmit data between a server and a web application or between different components of a distributed application.
One common use of JSON is to exchange data between a web server and a client, such as a web browser. When sending data to a server, the data has to be in the form of a string. The JSON.stringify() method can be used to convert a JavaScript object or array into a JSON string.
For example:
const data = {
name: 'Alice',
age: 30
};
const dataString = JSON.stringify(data);
console.log(dataString); // Output: '{"name":"Alice","age":30}'
Here, the data object is converted into a JSON string using the JSON.stringify() method. The resulting string can then be sent to a server using an HTTP request.
Related Topic:
Share Above MCQ