title: Expected STRING but was BEGIN_OBJECT
body: <p>I've read a lot of answers about this error and I don't find the solution for mine maybe the class object isn't the same</p>
  
  <p>My error is : </p>
  
  <p>com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected STRING but was BEGIN_OBJECT</p>
  
  <p>So, I just trying to get an Object from JSON like this : </p>
  
  <pre><code>JsonObject mS1SystemStatusJsonObject = parameterEntries.getValue().getAsJsonObject();
  
  MS1SystemStatusResponse mS1SystemStatusResponse = gson.fromJson(mS1SystemStatusJsonObject, MS1SystemStatusResponse.class);
  </code></pre>
  
  <p>my JsonObject is :</p>
  
  <pre><code>{
   "WARNING_CONDITION_LIST":
    {
     "warningConditionList": {"warningCondition":"BLACK_POSTAL_INK_WF_COND"}
     },
   "DISABLING_CONDITION_LIST": {"disablingConditionList":""},
   "CurrentErrorList":"",
   "LockState":"lockspend",
  "SystemReadyState":true
  }
  </code></pre>
  
  <p>My differents POJO (i don't put get and set for short the code) : </p>
  
  <pre><code>public class MS1SystemStatusResponse{
  
  @SerializedName("LockState")
  String lockState;
  
  @SerializedName("SystemReadyState")
  Boolean systemReadyState;
  
  @SerializedName("WARNING_CONDITION_LIST")
  WARNING_CONDITION_LIST warningConditionListMy;
  
  @SerializedName("DISABLING_CONDITION_LIST")
  DISABLING_CONDITION_LIST disablingConditionListMy;
  
  @JsonAdapter(EmptyStringAsNullTypeAdapter.class)    
  @SerializedName("CurrentErrorList")
  CurrentErrorList currentErrorList;
  
  
  public class WARNING_CONDITION_LIST {
  
  @SerializedName(value = "warningConditionList")
  @JsonAdapter(EmptyStringAsNullTypeAdapter.class)
  WarningConditionList warningConditionList;
  
  
  public class DISABLING_CONDITION_LIST {
  
  @SerializedName(value = "disablingConditionList")
  @JsonAdapter(EmptyStringAsNullTypeAdapter.class)
  DisablingConditionList disablingConditionList;
  
  public class CurrentErrorList {
  
  @SerializedName(value = "Error")
  private Error error;
  
  
  public class WARNING_CONDITION_LIST {
  
  @SerializedName(value = "warningConditionList")
  @JsonAdapter(EmptyStringAsNullTypeAdapter.class)
  WarningConditionList warningConditionList;
  
  
  public class WarningConditionList {
  
  @SerializedName(value = "warningCondition")
  String warningCondition;
  </code></pre>
  
  <p>Here is the full stack trace and another class that i've forgot to add before : </p>
  
  <p>Stacktrace :</p>
  
  <pre><code>java.lang.IllegalStateException: Expected STRING but was BEGIN_OBJECT
      com.google.gson.internal.bind.JsonTreeReader.nextString(JsonTreeReader.java:154)
      com.pb.marqueo.connect.plus.api.common.model.response.EmptyStringAsNullTypeAdapter.read(EmptyStringAsNullTypeAdapter.java:24)
      com.pb.marqueo.connect.plus.api.common.model.response.EmptyStringAsNullTypeAdapter.read(EmptyStringAsNullTypeAdapter.java:10)
      com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:117)
      com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:217)
      com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:117)
      com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:217)
      com.google.gson.Gson.fromJson(Gson.java:861)
      com.google.gson.Gson.fromJson(Gson.java:926)
      com.google.gson.Gson.fromJson(Gson.java:899)
      com.pb.marqueo.connect.plus.api.core.service.impl.ConnectPlusServicesImpl.getMS1SystemStatus(ConnectPlusServicesImpl.java:410)
      com.pb.marqueo.connect.plus.api.core.facade.impl.ConnectPlusBusinessServicesImpl.startProduction(ConnectPlusBusinessServicesImpl.java:1236)
      com.pb.marqueo.connect.plus.rest.services.impl.ConnectPlusControllerImpl.startProd(ConnectPlusControllerImpl.java:280)
      sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      java.lang.reflect.Method.invoke(Method.java:498)
      org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:215)
      org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
      org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
      org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:749)
      org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:689)
      org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83)
      org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:938)
      org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870)
      org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
      org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:863)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:644)
      org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
      org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
      com.pb.marqueo.common.filter.OriginFilter.doFilter(OriginFilter.java:70)
  </code></pre>
  
  <p>Class Adapter : </p>
  
  <pre><code>public class EmptyStringAsNullTypeAdapter extends TypeAdapter&lt;String&gt; {
  
      @Override
      public void write(JsonWriter out, String value) throws IOException {
          out.value(value);
      }
  
      @Override
      public String read(JsonReader in) throws IOException {
          if (in.peek() == JsonToken.NULL) {
              in.nextNull();
              return null;
          }
  
          String result = in.nextString();
          if ("".equals(result)) {
              return null;
          }
          return result;
      }
  }
  </code></pre>
  
  <p>I turn around since 1 week :(</p>