6.10.3 The toJSON() Method
Object.prototype does not actually define a toJSON() method, but the JSON.stringify() method (see §6.9 ) looks for a toJSON() method on any object it is asked to serialize. If this method exists on the object to be serialized, it is invoked, and the return value is serialized, instead of the original object. See Date.toJSON() for an example.
6.10 Object Methods | 139欢迎转载,转载请注明来自一手册:http://yishouce.com/book/1/30464.html