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
也可以替换
const obj = JSON.parse(
JSON.stringify(resData)
.replace(/"subList":/g, '"children":')
.replace(/"id":/g, '"value":')
.replace(/"name":/g, '"label":'),
);