When the Gson's native fromJson method returns null (ex. when the JSON string is empty), a
java.lang.IllegalStateException: fromJson(json, typeToken<T>()) must not be null
exception is thrown due to the extension function being defined as Gson.fromJson(json: String): T. I developed a workaround for it (note the nullable type T)
When the Gson's native
fromJson
method returnsnull
(ex. when the JSON string is empty), aexception is thrown due to the extension function being defined as
Gson.fromJson(json: String): T
. I developed a workaround for it (note the nullable type T)I'm unsure whether this would be the correct approach, thus I'm not submitting a PR.