Skip to content

Instantly share code, notes, and snippets.

@oatpano
Last active February 25, 2018 19:22
Show Gist options
  • Save oatpano/796761d4a5596ed49dfaa0275d332e32 to your computer and use it in GitHub Desktop.
Save oatpano/796761d4a5596ed49dfaa0275d332e32 to your computer and use it in GitHub Desktop.
GetJsonFixModelClassKotlin
fun MyDataModel Context.getJsonFixModelClassKotlin(@RawRes jsonFileRes: Int): MyDataModel {
val inputStream = this.resources.openRawResource(jsonFileRes)
val bufferReader = BufferedReader(InputStreamReader(inputStream))
return gson.fromJson(bufferReader, MyDataModel::class.java)
}
// วิธีเรียกใช้
getJsonFixModelClassKotlin(R.raw.json_text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment