Fix bugs and add improvements
This commit is contained in:
parent
555be9d602
commit
ba4dd5c470
10 changed files with 26 additions and 21 deletions
|
|
@ -2,11 +2,14 @@ import { serializableMapping } from './serializable-mapping';
|
|||
|
||||
export const deserialize = (json: string): any => {
|
||||
return JSON.parse(json, (k, v) => {
|
||||
const possibleType = v[0];
|
||||
const overridableConstructor = serializableMapping.get(possibleType);
|
||||
if (overridableConstructor) {
|
||||
v.shift();
|
||||
return new overridableConstructor.constructor(...v);
|
||||
if (v !== null && Object.prototype.hasOwnProperty.call(v, '0')) {
|
||||
const possibleType = v[0];
|
||||
const overridableConstructor = serializableMapping.get(possibleType);
|
||||
if (overridableConstructor) {
|
||||
v.shift();
|
||||
return new overridableConstructor.constructor(...v);
|
||||
}
|
||||
return v;
|
||||
}
|
||||
return v;
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue