Created
February 4, 2020 15:08
-
-
Save glockbender/966bc80383e0893b47cc6edab7e4969d 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
inline fun <reified T> ObjectMapper.readAsList(serialized: String): List<T> = | |
this.typeFactory.constructCollectionType(List::class.java, T::class.java) | |
.let { collectionType -> | |
try { | |
this.readValue(serialized, collectionType) | |
} catch (e: Exception) { | |
throw RuntimeException("Cannot deserialize list of ${T::class.simpleName}") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment