Created
July 16, 2021 08:06
-
-
Save oscargrgm/3ab60ce0cd5d4f14ec60d761c0ab00bb to your computer and use it in GitHub Desktop.
Deserialize any String into an object using Gson.
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
private inline fun <reified T> String.asModel(): T = Gson().fromJson(this, T::class.java) | |
// val result: String = ... | |
// val model = result.asModel<AnyModel>() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment