How-to articles, tricks, and solutions about GSON

Converting JSON data to Java object

To convert JSON data to a Java object, you can use the fromJson method of the Gson class.

GSON throwing "Expected BEGIN_OBJECT but was BEGIN_ARRAY"?

If GSON is throwing a JsonSyntaxException with the message "Expected BEGIN_OBJECT but was BEGIN_ARRAY", it means that you are trying to parse a JSON array as if it were a JSON object.