mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-04 06:57:03 +03:00
cleanup some json code
This commit is contained in:
parent
f23b7205c6
commit
528b6cd096
5 changed files with 19 additions and 12 deletions
|
|
@ -80,11 +80,9 @@ export class AbstractModel {
|
|||
}
|
||||
|
||||
revivePropertiesFromJson(json) {
|
||||
let model = this.constructor;
|
||||
if (!model.validJson(json)) {
|
||||
return false;
|
||||
}
|
||||
forEachObjectEntry(json, (key, value) => {
|
||||
const model = this.constructor,
|
||||
valid = model.validJson(json);
|
||||
valid && forEachObjectEntry(json, (key, value) => {
|
||||
if ('@' !== key[0]) try {
|
||||
// key = key[0].toLowerCase() + key.slice(1);
|
||||
switch (typeof this[key])
|
||||
|
|
@ -103,9 +101,11 @@ export class AbstractModel {
|
|||
this[key] = typeCast(this[key], value);
|
||||
break;
|
||||
case 'undefined':
|
||||
console.log(`Undefined ${model.name}.${key} set`);
|
||||
this[key] = value;
|
||||
// fall through
|
||||
default:
|
||||
break;
|
||||
// default:
|
||||
// console.log((typeof this[key])+` ${model.name}.${key} not revived`);
|
||||
// console.log((typeof this[key])+' '+(model.name)+'.'+key+' not revived');
|
||||
}
|
||||
} catch (e) {
|
||||
|
|
@ -113,7 +113,7 @@ export class AbstractModel {
|
|||
console.error(e);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
return valid;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue