Created
April 14, 2021 08:40
-
-
Save hosseiniSeyRo/88638e9e8b26be0b7ea953e4b20b22fa to your computer and use it in GitHub Desktop.
Convert JsonString to Object
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
fun <T> convertJsonStringToObject(jsonString: String?, objectClass: Class<T>?): T { | |
return Gson().fromJson(jsonString, objectClass) | |
} | |
fun <T> convertJsonStringToObjectList(jsonString: String): List<T> { | |
return Gson().fromJson(jsonString, object : TypeToken<List<T?>?>() {}.type) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment