Created
April 28, 2020 11:03
-
-
Save salihyalcin/74c860a39c5da9f054e01d858d17876b to your computer and use it in GitHub Desktop.
Kotlin json parsing.
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> Context.jsonToClass(@RawRes resourceId: Int): T = | |
Gson().fromJson(resources.openRawResource(resourceId).bufferedReader().use { it.readText() }, T::class.java) | |
inline fun <reified T> Context.fromRemoteJsonToClass(json : String): T = Gson().fromJson(json, T::class.java) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment