Skip to content
Advertisement

“Expected BEGIN_OBJECT but was STRING at line 1 column 1”

I have this method:

JavaScript

And I want to parse a JSON with:

JavaScript

But I get an error message:

com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1

Advertisement

Answer

Even without seeing your JSON string you can tell from the error message that it is not the correct structure to be parsed into an instance of your class.

Gson is expecting your JSON string to begin with an object opening brace. e.g.

JavaScript

But the string you have passed to it starts with an open quotes

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement