Created
May 3, 2020 19:53
-
-
Save pichillilorenzo/608c1e6aec1bae769d02adb115b9d045 to your computer and use it in GitHub Desktop.
@JsonClassType() example
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
import { JsonClassType } from 'jackson-js'; | |
class Foo2 { } | |
class Foo { | |
@JsonClassType({type: () => [Number]}) | |
barNumber: number; | |
@JsonClassType({type: () => [String]}) | |
barString: string; | |
@JsonClassType({type: () => [Foo2]}) | |
barFoo2: Foo2; | |
@JsonClassType({type: () => [Array, [Number]]}) | |
barNumberArray: number[] = []; | |
@JsonClassType({type: () => [Array, [Foo2]]}) | |
barFoo2Array: Foo2[] = []; | |
@JsonClassType({type: () => [Map, [String, Foo2]]}) | |
barMap: Map<string, Foo2> = new Map(); | |
@JsonClassType({type: () => [Object, [String, Foo2]]}) | |
barObjectLiteral: Record<string, Foo2> = {}; | |
@JsonClassType({type: () => [Set, [String]]}) | |
barSet: Set<string> = new Set(); | |
@JsonClassType({type: () => [Array, [Set, [Foo2]]]}) | |
barMix: Array<Set<Foo2>> = []; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment