com.google.gson.JsonSyntaxException: Expected a com.g oogle.gson.JsonObject but was com.google.gson.JsonPrimitive at com.google.gson.internal.bind.TypeAdapters$35$1.read(TypeAdapters.jav a:917) at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(Type AdapterRuntimeTypeWrapper.java:40) at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.re ad(CollectionTypeAdapterFactory.java:82) at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.re ad(CollectionTypeAdapterFactory.java:61) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(Ref lectiveTypeAdapterFactory.java:116) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.re ad(ReflectiveTypeAdapterFactory.java:216)

Searched on Google with the first line of a JAVA stack trace?

We can recommend more relevant solutions and speed up debugging when you paste your entire stack trace with the exception message. Try a sample exception.

Recommended solutions based on your search

Samebug tips

,

Your json input might be invalid. Try checking it in a validator like https://jsonlint.com

,

Your custom gson deserializer might have a bug. Try to write a unit test that checks proper deserialization of only that class by forging a json that contains a single field of that type.

Solutions on the web

via GitHub by hmspain
, 1 year ago
Expected a com.g oogle.gson.JsonObject but was com.google.gson.JsonPrimitive at
via GitHub by seanford
, 1 year ago
Expected a com.g oogle.gson.JsonObject but was com.google.gson.JsonPrimitive at com.google.gson.internal.bind.TypeAdapters$35$1.read(TypeAdapters.jav a:917) at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(Type
via GitHub by hmspain
, 1 year ago
Expected a com.g oogle.gson.JsonObject but was com.google.gson.JsonPrimitive at com.google.gson.internal.bind.TypeAdapters$35$1.read(TypeAdapters.jav a:917) at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(Type
via Stack Overflow by Kayvar
, 1 year ago
java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT at line 1 column 186 path $.
via Stack Overflow by Bolic
, 2 years ago
java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2
via Stack Overflow by Adam Law
, 2 years ago
java.io.EOFException: End of input at line 1 column 71
com.google.gson.JsonSyntaxException: Expected a com.g oogle.gson.JsonObject but was com.google.gson.JsonPrimitive at com.google.gson.internal.bind.TypeAdapters$35$1.read(TypeAdapters.jav a:917) at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(Type AdapterRuntimeTypeWrapper.java:40) at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.re ad(CollectionTypeAdapterFactory.java:82) at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.re ad(CollectionTypeAdapterFactory.java:61) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(Ref lectiveTypeAdapterFactory.java:116) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.re ad(ReflectiveTypeAdapterFactory.java:216)
at com.google.gson.Gson.fromJson(Gson.java:879)
at com.google.gson.Gson.fromJson(Gson.java:944)

Users with the same issue

Samebug visitor profile picture
Unknown user
Once, 1 year ago
Samebug visitor profile picture
Unknown user
Once, 1 year ago
Samebug visitor profile picture
Unknown user
Once, 1 year ago
5 times, 1 year ago
Samebug visitor profile picture
Unknown user
Once, 1 year ago
15 more bugmates

Know the solutions? Share your knowledge to help other developers to debug faster.