title: How do I get a response from a post request if the response is different from the post class
body: <p>I'm using retrofit to pass login details to my server through an api. The post request for the api takes in just email and password but the response returns a different Json format from what the POJO class contains. How do I handle the api response?</p>
  
  <p>I've tried returning the response as a JSONObject to help get the Json from the api but it doesn't work.
  The API returns a success json containing the user name and a login token.</p>
  
  <pre><code>    Call&lt;LoginPost&gt; call = apiLink.loginUser(useremail, userpassword);
  
      call.enqueue(new Callback&lt;LoginPost&gt;() {
          @Override
          public void onResponse(Call&lt;LoginPost&gt; call, Response&lt;LoginPost&gt; response) {
              if(!response.isSuccessful()){
                  String code = Integer.toString(response.code());
                  Toast.makeText(LoginPage.this, code, Toast.LENGTH_LONG).show();
              }
              else {
               LoginPost postResponse = response.body();
  
               Log.e("viewResponse", 
                     postResponse.getSuccessResponse().toString());
  
                 return;
              }
          }
  
          @Override
          public void onFailure(Call&lt;LoginPost&gt; call, Throwable t) {
              Log.e("error in createNewUser",  t.getMessage());
          }
      });
  </code></pre>
  
  <p>the post class:</p>
  
  <pre><code>@SerializedName("email")
  String userEmail;
  
  
  @SerializedName("password")
  String userPassword;
  
  public JSONObject getSuccessResponse() {
      return successResponse;
  }
  
  @SerializedName("success")
  JSONObject successResponse;
  
  
  public String getUserEmail() {
      return userEmail;
  }
  
  
  public String getUserPassword() {
      return userPassword;
  }
  </code></pre>