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


3 months ago

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.


3 months ago

Solutions on the web271

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
java.lang.IllegalStateException: BEGIN_OBJECT expected, but met STRING

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

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

Solution icon of stackoverflow
java.lang.IllegalStateException: Expected BEGIN_OBJECT but was 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 STRING but was BEGIN_OBJECT

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, 3 months ago
Once, 5 months ago
Samebug visitor profile picture
Unknown user
Once, 9 months ago
4 times, 9 months ago
5 times, 11 months ago
23 more bugmates