我有一个场景,我必须解析猫鼬对象并将其转换为标准javascript对象,但是我无法做到这一点,因为猫鼬在对象内部具有方法。有人可以帮我吗?
猫鼬对象
{
key: {
type: String,
unique: true,
min: 2,
max: 50,
validate: {
validator: function(value: string) {
return /^[A-Za-z0-9 ]{3,20}$/.test(value);
},
message: 'key is invalid.',
},
required: [true, 'key is required'],
},
key1: {
type: String,
validate: {
validator: function(value: string) {
return /^[A-Za-z0-9 ]{3,20}$/.test(value);
},
message: 'key1 is invalid',
},
required: [true, 'key1 is required'],
},
};
预期产量
{
key:{
unique: true,
type: 'string',
min:2,
max:50,
validation: /^[A-Za-z0-9 ]{3,20}$/
},
key1: {
type: 'string',
validation: /^[A-Za-z0-9 ]{3,20}$/
}
}