JSON.stringify({a:1,b:2,c:undefined});//'{"a":1,"b":2}'
如何JSON.stringify({a:1,b:2,c:undefined});//'{"a":1,"b":2,"c":""}'
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
重新定义
undefined使之成为""。因为重新定义全局
undefined可能引起其它问题,所以需要封装在一个函数范围内http://stackoverflow.com/questions/26540706/json-stringify-removes-hash-keys-with-undefined-values
从js某个版本后,不能覆盖再
undefined的值。