serializer.ts
Advanced tools
Comparing version 0.0.7 to 0.0.8
{ | ||
"name": "serializer.ts", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"description": "Proper serialization and deserialization raw json objects to classes in Typescript", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
@@ -40,14 +40,36 @@ "use strict"; | ||
return "break"; | ||
if (object[key] instanceof Function) | ||
return "break"; | ||
if (options && options.skipStartedWith && | ||
key.substr(0, options.skipStartedWith.length) === options.skipStartedWith) | ||
return "break"; | ||
var type = this_1.getType(cls, key); | ||
if (object[key] instanceof Array) { | ||
// if (object[key].length > 0 && !type && operationType === "deserialization") | ||
// throw new TypeMissingError(cls, key); | ||
if (object[key].length > 0 && type) { | ||
newObject[key] = object[key].map(function (arrayItem) { return _this.convert(type, arrayItem, operationType); }); | ||
if (typeof object[key] !== "function") { | ||
if (options && options.skipStartedWith && | ||
key.substr(0, options.skipStartedWith.length) === options.skipStartedWith) | ||
return "break"; | ||
var type_1 = this_1.getType(cls, key); | ||
if (object[key] instanceof Array) { | ||
// if (object[key].length > 0 && !type && operationType === "deserialization") | ||
// throw new TypeMissingError(cls, key); | ||
if (object[key].length > 0 && type_1) { | ||
newObject[key] = object[key].map(function (arrayItem) { return _this.convert(type_1, arrayItem, operationType); }); | ||
} | ||
else { | ||
newObject[key] = object[key]; | ||
} | ||
} | ||
else if (object[key] instanceof Object || type_1) { | ||
if (!type_1 && operationType === "deserialization") | ||
throw new TypeMissingError_1.TypeMissingError(cls, key); | ||
if (type_1 === Date) { | ||
newObject[key] = new Date(object[key]); | ||
} | ||
else if (type_1 === String) { | ||
newObject[key] = String(object[key]); | ||
} | ||
else if (type_1 === Number) { | ||
newObject[key] = Number(object[key]); | ||
} | ||
else if (type_1 === Boolean) { | ||
newObject[key] = Boolean(object[key]); | ||
} | ||
else { | ||
newObject[key] = this_1.convert(type_1, object[key], operationType); | ||
} | ||
} | ||
else { | ||
@@ -57,24 +79,2 @@ newObject[key] = object[key]; | ||
} | ||
else if (object[key] instanceof Object || type) { | ||
if (!type && operationType === "deserialization") | ||
throw new TypeMissingError_1.TypeMissingError(cls, key); | ||
if (type === Date) { | ||
newObject[key] = new Date(object[key]); | ||
} | ||
else if (type === String) { | ||
newObject[key] = String(object[key]); | ||
} | ||
else if (type === Number) { | ||
newObject[key] = Number(object[key]); | ||
} | ||
else if (type === Boolean) { | ||
newObject[key] = Boolean(object[key]); | ||
} | ||
else { | ||
newObject[key] = this_1.convert(type, object[key], operationType); | ||
} | ||
} | ||
else { | ||
newObject[key] = object[key]; | ||
} | ||
}; | ||
@@ -81,0 +81,0 @@ var this_1 = this; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33205