Created
February 11, 2018 18:55
-
-
Save krishna-acondy/824b9d151903328d308473c1aea90b59 to your computer and use it in GitHub Desktop.
Pizza Serializer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class PizzaSerializer { | |
fromJson(json: any): Pizza { | |
const pizza = new Pizza(); | |
pizza.id = json.id; | |
pizza.name = json.name; | |
pizza.cookedOn = moment(json.cookedOn, 'mm-dd-yyyy hh:mm'); | |
return pizza; | |
} | |
toJson(pizza: Pizza): any { | |
return { | |
id: pizza.id, | |
name: pizza.name | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment