Skip to content

Instantly share code, notes, and snippets.

@xmlking
Created January 2, 2018 04:15
Show Gist options
  • Save xmlking/cd48ac7fc6bd98173e9bdf6d479eb4c8 to your computer and use it in GitHub Desktop.
Save xmlking/cd48ac7fc6bd98173e9bdf6d479eb4c8 to your computer and use it in GitHub Desktop.
Kotlin data class with second constructor !
@NoArg
@JsonIgnoreProperties(ignoreUnknown = true)
data class Request(
var AAA: String?,
var BBB : String?,
var CCC: String?
) {
constructor(raw: String): this(null,null, null) {
val mapper = jacksonObjectMapper()
val request = mapper.readValue<Request>(raw)
this.AAA = request.AAA
this.BBB = request.BBB
this.CCC = request.CCC
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment