Exception in thread "main" com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:200)
at com.google.gson.Gson.fromJson(Gson.java:810)
at com.google.gson.Gson.fromJson(Gson.java:775)
at com.google.gson.Gson.fromJson(Gson.java:724)
at com.google.gson.Gson.fromJson(Gson.java:696)
at JsonToGsonExample.main(JsonToGsonExample.java:52)
Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
JsonSyntaxException is when you are trying to parse a JSON String and it is not well formatted. BEGIN_OBJECT is the start of a JSON object and it should be open curly braces {, which is surely missing
Fix:
- Add the missing { for the JSON String
- If the error is not on line 1 column 1, just follow the line and column to reach to the location within your JSON and add the missing curly brace.
- Make sure your JSON String is valid. You may make use of Online JSON Validators (careful not to have sensitive data)
Before fix: "name":"ABC", "age":22}
Ater fix: { "name":"ABC", "age":22}
- Error: Can not find the tag library descriptor for
- Create a Database Table using JDBC PreparedStatement
- Java JDBC Select Multiple Records from table as List using PreparedStatement
- Java Jackson with Maven Example
- [fix] Java JDBC ConnectException: Connection refused
- Spring Boot: Transactions Management with JDBCTemplate Example
- Java Get Current Date for a Specific Time Zone
- What are the 8 Primitive Data Types in Java
- Java JDBC: Insert Java 8 LocalDate and Time using PreparedStatement
- Maven Eclipse (M2e) No archetypes currently available
- How to Sort a LinkedList in Java
- [Fatal Error] XML The markup in the document following the root element must be well-formed.
- Split a String in Java with Examples
- Struts 2 : There is no Action mapped for namespace [/] and action name [form] associated with context path [/proj]
- Truncate table using Java JDBC Example
- Java: Generate random numbers within a range
- Parse XML file in Java using DOM Parser
- How to get Client IP address using Java Code Example
- JDBCTemplate Querying Examples with Spring Boot 3
- [Java Threads] Should we extend Thread Class or implement Runnable interface
- String Boot + Redis - SET and GET String Commands Examples
- Setting up Spring Boot 3 + Maven + MySQL + JDBC Example
- Spring Boot: JdbcTemplate Update Query With Parameters Example
- Java Split String by Spaces
- Unbound classpath container: JRE System Library [JavaSE-1.7]
- 🔥 [BTS ARMY] #ExaBLINK, #ExaARMY hashtags trending worldwide - BTS
- Program 2: Print your name using print() function - 1000+ Python Programs - Python-Programs
- How to make EditText text to uppercase or lowercase on macOS - MacOS
- Get cURL command from Chrome Inspect Network HTTP URL - cURL
- Convert Java String to JSON Object using Jackson - Java
- Create Nested Directories using mkdir Command - Linux
- Command to Sort File In Reverse Order [Unix/Linux/macOS] - Bash
- [fix] Spring Boot Data JPA - No identifier specified for entity - Java