有快速过滤的对象的方法?
数据库返回: {"_id":“56a96ab80a41e0f0333bc19e”, “accessToken”:“00f38da0-0f4f-4409-bcb7-24c776d4a653”, “avatar”:"", “user_name”:“2696071536”, “email”:"[email protected]", “password”:“e9e9b762c20d4ad091fdf54d4bb828cc”, "__v":0, }
如何快速过滤 直返会需要的 { “avatar”:"", “user_name”:“2696071536”, “email”:"[email protected]", }
8 回复
可以看一下这个: https://github.com/JSSDKCN/node-form-validator var extractedData = validator.json.extract(json, conf));
var src = {
"_id":“56a96ab80a41e0f0333bc19e”,
“accessToken”:“00f38da0-0f4f-4409-bcb7-24c776d4a653”,
“avatar”:"",
“user_name”:“2696071536”,
“email”:"[email protected]",
“password”:“e9e9b762c20d4ad091fdf54d4bb828cc”, "__v":0,
}
var dst = {
avatar: src.avatar,
user_name: src.user_name,
email: src.email,
}
不知道是不是你想要的。