java.lang.ClassCastException: com.google.gson.JsonSyntaxException cannot be cast to com.github.kittinunf.fuel.core.FuelError
See original GitHub issueSuppose you have a JSON like
{
"success": 1,
"errors": [],
"update_time": 1542190271,
}
And a parsing class like
data class YourResponse(
val success: Int,
val update_time: Int,
val errors: ErrorsResponse?
) {
data class ErrorsResponse(
val data: List<String>?
)
class Deserializer : ResponseDeserializable<YourResponse> {
override fun deserialize(content: String): YourResponse? =
Gson().fromJson(content, YourResponse::class.java)
}
}
If you parse this JSON in interactor like
api.getJson().awaitObjectResponse(YourResponse.Deserializer()).third
,
you will receive java.lang.ClassCastException: com.google.gson.JsonSyntaxException cannot be cast to com.github.kittinunf.fuel.core.FuelError
,
while a real exception is com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 24 path $.errors
.
It wastes much time to understand in a case of long JSON.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6
Top Results From Across the Web
[fuel-core] FuelError stacktrace is misleading #515 - GitHub
java.lang.ClassCastException: com.google.gson.JsonSyntaxException cannot be cast to com.github.kittinunf.fuel.core.FuelError #531.
Read more >Could not initialize class com.github.kittinunf.fuel.core ...
I got errors when I call Fuel API but I couldn't realize what's wrong. My question: Does Fuel ... FuelManager] with root cause...
Read more >What is the proper way to deserialize a List of things? #233
java.lang.ClassCastException: com.google.gson.internal.LinkedTreeMap cannot be cast to io.smartly.balex.receiver.CommitStatus.
Read more >fuel/FuelGson.kt at master · kittinunf/fuel - GitHub
import com.github.kittinunf.fuel.core.response. import com.google.gson.Gson. import com.google.gson.reflect.TypeToken. import java.io.Reader.
Read more >Caused by: com.github.kittinunf.fuel.core.HttpException: HTTP ...
@SuppressLint("ShowToast") private fun getData(npa: String) { progressbar.visibility = View.VISIBLE val json = JSONObject() json.put("npa", ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
NikkyAI has fixed this after releasing 1.16.0.
You can either use jitpack to get the snapshot version, or wait for 2.0.0
On Wed, 14 Nov 2018, 12:51 A, notifications@github.com wrote:
@SleeplessByte yes. Maybe I wrote too short, and some more information has been lost.