Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save pichillilorenzo/a723b818f66db39dc15d3498e57c804c to your computer and use it in GitHub Desktop.
Save pichillilorenzo/a723b818f66db39dc15d3498e57c804c to your computer and use it in GitHub Desktop.
@JsonProperty() and @JsonClassType() decorators
class Book {
@JsonProperty() @JsonClassType({type: () => [String]})
name: string;
@JsonProperty() @JsonClassType({type: () => [String]})
category: string;
}
class Writer {
@JsonProperty() @JsonClassType({type: () => [Number]})
id: number;
@JsonProperty() @JsonClassType({type: () => [String]})
name: string;
@JsonProperty() @JsonClassType({type: () => [Array, [Book]]})
books: Book[] = [];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment