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 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 web596

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
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 ssuukk
, 7 months ago
java.lang.IllegalStateException: NAME expected, but met BEGIN_OBJECT

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

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

Solution icon of github
java.lang.IllegalStateException: Expected a name but was NULL at line 1 column 30 path $.biggest_ride_distance

Solution icon of stackoverflow
java.lang.IllegalStateException: Expected a name but was NULL at line 24 column 39 path $[1].objectOne

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

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, 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
14 more bugmates