Skip to content

Commit

Permalink
fixed issue when empty arrays cannot be deserailized
Browse files Browse the repository at this point in the history
  • Loading branch information
Umed Khudoiberdiev committed Feb 27, 2016
1 parent a621d37 commit 61da8c2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "serializer.ts",
"version": "0.0.2",
"version": "0.0.3",
"description": "Proper serialization and deserialization raw json objects to classes in Typescript",
"license": "Apache-2.0",
"readmeFilename": "README.md",
Expand Down
4 changes: 3 additions & 1 deletion src/Serializer.ts
Expand Up @@ -38,7 +38,9 @@ export class Serializer {
const type = this.getType(cls, key);

if (object[key] instanceof Array) {
if (!type) throw new TypeMissingError(cls, key);
if (object[key].length > 0 && !type)
throw new TypeMissingError(cls, key);

newObject[key] = object[key].map((arrayItem: any) => this.convert(type, arrayItem, operationType));

} else if (object[key] instanceof Object || type) {
Expand Down

0 comments on commit 61da8c2

Please sign in to comment.