Like the Java language, objects can be serialized and deserialized in JavaScript to save the object. In the ECMAScript 5 standard, object serialization in JavaScript is implemented through JSON.stringify(), while deserialization is implemented through JSON.parse():
For browsers that only support the ECMAScript 3 standard, you can use json2.js written by Douglas Crockford (https://github.com/douglascrockford/JSON-js).
During the process of serializing the object, NaN, Infinity and -Infinity will be serialized into "null"; the Date object will be serialized into a string representing the corresponding time (but when deserialized using JSON.parse() , the time string will exist as an ordinary string and will not be reconstructed as a Date object).
When using JSON.stringify() to serialize an object, the serialized property is limited to the enumerable property of the object itself (Own). When JSON.stringify() is running, JavaScript will first check whether there is a toJSON() method in the object that needs to be serialized. If the toJSON() method exists, the method is called and the result returned is used as the target of serialization. If the toJSON() method does not exist, the default serialization method is used.