Last active
February 25, 2018 19:22
-
-
Save oatpano/a3ca422f290784a143f4db04586cf719 to your computer and use it in GitHub Desktop.
GetJsonGenericKotlin
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
fun 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