Created
August 3, 2022 12:25
-
-
Save arnabkd/411e32e59fc78e032c5186c2584912b8 to your computer and use it in GitHub Desktop.
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 com.fasterxml.jackson.annotation.JsonTypeInfo | |
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper | |
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME) | |
sealed class Principal | |
object AnonymousUser : Principal() { | |
val _empty: String? = null | |
} | |
// other implementations of Principal | |
fun main() { | |
// jacksonObjectMapper() is a function in jackson which creates an object mapper with the Kotlin module | |
val input = jacksonObjectMapper().writeValueAsString(AnonymousUser) | |
val principal = jacksonObjectMapper().readValue(input, Principal::class.java) | |
println(principal) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment