Last active
February 25, 2018 19:21
-
-
Save oatpano/ee2710e365d68fe41fbb0d8fc1737917 to your computer and use it in GitHub Desktop.
GetJsonGenericKotlin Success
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.getJsonGenericKotlin(@RawRes jsonFileRes: Int): T { | |
val inputStream = this.resources.openRawResource(jsonFileRes) | |
val bufferReader = BufferedReader(InputStreamReader(inputStream)) | |
return gson.fromJson(bufferReader, T::class.java) | |
} | |
// วิธีเรียกใช้ | |
getJsonGenericKotlin<MyDataModel>(R.raw.json_text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment