com.google.gson.JsonSyntaxException: 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 ```


Samebug tips

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 web

Solution icon of github
via GitHub by mlesikov
, 9 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 sabrinawilske
, 9 months ago
java.lang.IllegalStateException: Expected STRING but was BEGIN_OBJECT

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

Solution icon of github
via GitHub by SPARKSTA
, 1 month ago
java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1

Solution icon of stackoverflow
java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT at line 1 column 2

Solution icon of stackoverflow
java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 27

Solution icon of stackoverflow
java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT at line 1 column 186 path $.

Solution icon of web
java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1

Solution icon of web
via hortonworks.com by Unknown author, 1 year ago
java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 6

Solution icon of web
via hortonworks.com by Unknown author, 1 year ago
java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 10

Stack trace

com.google.gson.JsonSyntaxException: 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

```
	at com.google.gson.Gson.fromJson(Gson.java:766)
	at com.stanfy.gsonxml.GsonXml.fromXml(GsonXml.java:92)
	at com.stanfy.gsonxml.GsonXml.fromXml(GsonXml.java:66)
	at com.stanfy.gsonxml.GsonXml.fromXml(GsonXml.java:52)
	at com.evo.adm.common.server.email.ListsTest.primitiveListIntSameName(ListsTest.java:232)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
	at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:77)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

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, 10 months ago
5 times, 11 months ago
14 more bugmates