com.google.gson.JsonSyntaxException

java.lang.IllegalStateException: BEGIN_OBJECT expected, but met STRING Scopes: INSIDE_OBJECT>NAME>INSIDE_OBJECT>INSIDE_EMBEDDED_ARRAY>INSIDE_OBJECT Closed tags: 'Class3'/3 Token: null Tokens queue: null Values queue: , null


Samebug tips2

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.

Don't give up yet. Our experts can help. Paste your full stack trace to get a solution.


Solutions on the web610

Solution icon of github
java.lang.IllegalStateException: BEGIN_OBJECT expected, but met STRING Scopes: INSIDE_OBJECT>NAME>INSIDE_OBJECT>INSIDE_EMBEDDED_ARRAY>INSIDE_OBJECT Closed tags: 'Class3'/3 Token: null Tokens queue: null Values queue: , null

Solution icon of github
via GitHub by mlesikov
, 7 months ago
java.lang.IllegalStateException: STRING expected, but met NAME Scopes: INSIDE_OBJECT>NAME>INSIDE_OBJECT Closed tags: Token: null Tokens queue: BEGIN_OBJECT, NAME, STRING, null Values queue: response, @name, test, null ```

Solution icon of github
via GitHub by ssuukk
, 7 months ago
java.lang.IllegalStateException: NAME expected, but met BEGIN_OBJECT

Solution icon of github
java.lang.IllegalStateException: BEGIN_OBJECT expected, but met STRING

Solution icon of github
via GitHub by ssuukk
, 7 months ago
java.lang.IllegalStateException: NAME expected, but met STRING

Solution icon of stackoverflow
java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT

Solution icon of github
java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING

Solution icon of github
java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING

Solution icon of github
java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING

Solution icon of stackoverflow
via Stack Overflow by Unknown author, 1 year ago
java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING

Stack trace

  • com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: BEGIN_OBJECT expected, but met STRING Scopes: INSIDE_OBJECT>NAME>INSIDE_OBJECT>INSIDE_EMBEDDED_ARRAY>INSIDE_OBJECT Closed tags: 'Class3'/3 Token: null Tokens queue: null Values queue: , null at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:176) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:93) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:172) at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:40) at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:81) at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:60) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:93) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:172) at com.google.gson.Gson.fromJson(Gson.java:795) at com.stanfy.gsonxml.GsonXml.fromXml(GsonXml.java:96) at com.stanfy.gsonxml.GsonXml.fromXml(GsonXml.java:66) at com.stanfy.gsonxml.GsonXml.fromXml(GsonXml.java:52) at com.stanfy.gsonxml.GsonXml.fromXml(GsonXml.java:42) at com.stanfy.gsonxml.test.ListsTest.testAclXml(ListsTest.java:303)

Write tip

You have a different solution? A short tip here would help you and many other users who saw this issue last week.

Users with the same issue

Once, 1 month ago
Once, 3 months ago
Samebug visitor profile picture
Unknown user
Once, 7 months ago
4 times, 7 months ago
5 times, 9 months ago
23 more bugmates