Last active
February 26, 2018 16:06
-
-
Save oatpano/8acb71b7c334dab427da171dd469f065 to your computer and use it in GitHub Desktop.
GetJsonClassParameter
This file contains hidden or 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
public static T getJsonClassParameter(Context context, @RawRes int jsonFileRes, Class<T> classType) { | |
Gson gson = new Gson(); | |
InputStream inputStream = context.getResources().openRawResource(jsonFileRes); | |
BufferedReader bufferReader = new BufferedReader(new InputStreamReader(inputStream)); | |
return gson.fromJson(bufferReader, classType); | |
} | |
// วิธีเรียกใช้ | |
GenericJava.getJsonClassParameter(this, R.raw.json_text, MyDataModel.class) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment