Skip to content
This repository has been archived by the owner on Oct 1, 2019. It is now read-only.

Commit

Permalink
Add optional property option and update the forked project (#1)
Browse files Browse the repository at this point in the history
* Add optional property option

* Add protection when value does not exists

* Remove examplo project; change karma to jest; update packages; update informations
  • Loading branch information
delete authored Apr 25, 2019
1 parent 402eaab commit d5eb812
Show file tree
Hide file tree
Showing 86 changed files with 1,070 additions and 3,328 deletions.
16 changes: 16 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"plugins": [
[
"@babel/plugin-proposal-decorators",
{
"legacy": true
}
],
[
"@babel/plugin-proposal-class-properties",
{
"loose": true
}
],
]
}
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# This project is a fork from [dpopescu's project](https://github.com/dpopescu/ts-serializer)


# TS Serializer - [![Build Status](https://travis-ci.org/dpopescu/ts-serializer.svg?branch=master)](https://travis-ci.org/dpopescu/ts-serializer) [![NPM Downloads](https://img.shields.io/npm/dt/ts-serializer.svg)](https://img.shields.io/npm/dt/ts-serializer.svg) [![LICENSE](https://img.shields.io/npm/l/ts-serializer.svg)](https://img.shields.io/npm/l/ts-serializer.svg)
**TS Serializer** provides `TypeScript` decorators to help developers with serializing/deserializing TypeScript classes into and from JSON objects.

Expand Down Expand Up @@ -211,4 +214,36 @@ instance.deserialize({

console.log(instance.user.firstName); // Prints 'John'
console.log(instance.user.lastName); // Prints 'Doe'
```

#### optional
The `optional` option can be used when the property or the value may not exist.
```TypeScript
@Serialize({})
class User extends Serializable {
@SerializeProperty({})
public name:string;
@SerializeProperty({
optional: true
})
public age:number;
}

@Serialize({})
class Profile extends Serializable {
@SerializeProperty({
type: User
})
public user:User;
}

let instance:Profile = new Profile();
instance.deserialize({
user: {
firstName: 'John',
}
});

console.log(instance.user.firstName); // Prints 'John'
console.log(instance.user.age); // Prints 'null'
```
Binary file removed deploy_key.enc
Binary file not shown.
14 changes: 0 additions & 14 deletions example/.editorconfig

This file was deleted.

34 changes: 0 additions & 34 deletions example/.gitignore

This file was deleted.

31 changes: 0 additions & 31 deletions example/README.md

This file was deleted.

62 changes: 0 additions & 62 deletions example/angular-cli.json

This file was deleted.

14 changes: 0 additions & 14 deletions example/e2e/app.e2e-spec.ts

This file was deleted.

11 changes: 0 additions & 11 deletions example/e2e/app.po.ts

This file was deleted.

16 changes: 0 additions & 16 deletions example/e2e/tsconfig.json

This file was deleted.

38 changes: 0 additions & 38 deletions example/karma.conf.js

This file was deleted.

47 changes: 0 additions & 47 deletions example/package.json

This file was deleted.

32 changes: 0 additions & 32 deletions example/protractor.conf.js

This file was deleted.

6 changes: 0 additions & 6 deletions example/proxy.conf.json

This file was deleted.

17 changes: 0 additions & 17 deletions example/src/app/app.component.html

This file was deleted.

Loading

0 comments on commit d5eb812

Please sign in to comment.