1.JSON.stringify函数将一个JS对象转换成文本化的JSON,不能被文本化的属性会被忽略。如:循环引用,Symbol(),undefined
2.意外情况:在数组中,不可被stringify的元素用null填充
3.可以重写对象的toJSON(对象.prototype.toJSON = function(){}),使JSON.stringify返回指定的数据
4.JSON.stringify的完整定义:JSON.stringify(value, replacer?, space?)。
replacer是一个过滤函数或是一个数组,包含要被stringify的属性名。如果没有定义,默认所有属性都被stringify
space参数用来格式化输出结果,如:JSON.stringify(value, null, '\t');
转载于:https://my.oschina.net/zhcnlyh/blog/1519053