其他分享
首页 > 其他分享> > JSON.stringify 过滤字段

JSON.stringify 过滤字段

作者:互联网

 

let obj = {name: 'lili', age: 21, children: [{name: 'lucy', age: 18}]}
let str = JSON.stringify(obj, ["name", "children"])

console.log(str) // '{"name":"lili","children":[{"name":"lucy"}]}'
// 很有用,并且很方便,自动递归
https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify

标签:stringify,name,lili,JSON,过滤,let,children
来源: https://www.cnblogs.com/xiangsj/p/16296410.html