title: How to convert retrofit response body into JsonObject
body: <pre><code>public abstract class RetrofitBaseCallBack&lt;T&gt; implements Callback&lt;T&gt; {
      @Override
      public void onResponse(Call&lt;T&gt; call, Response&lt;T&gt; response) {
          int responseCode = response.code();
          if (responseCode == Constants.ServerResponse.Code.STATUS_OK
                  || responseCode == Constants.ServerResponse.Code.STATUS_CREATED_SUCCESS
                  || responseCode == Constants.ServerResponse.Code.STATUS_IN_PROGRESS
                  || responseCode == Constants.ServerResponse.Code.STATUS_NO_CONTENT
                  || responseCode == Constants.ServerResponse.Code.STATUS_ACCEPTED) {
              // i want to navigate to onResponseSuccess when "success":true
              onResponseSuccess(call, response);
          } else {
             //i want to navigate to onResponseFailure when "success":false
              onErrorResponse(call, response);
          }
      }
      }
  
      @Override
      public void onFailure(Call&lt;T&gt; call, Throwable t) {
          onRetrofitBaseCallBackFailure(call, t);
      }
  
      public abstract void onResponseSuccess(Call&lt;T&gt; call, Response&lt;T&gt; response);
  
      public abstract void onResponseFailure(Call&lt;T&gt; call, Response response, String message);
  
      public abstract void onRetrofitBaseCallBackFailure(Call&lt;T&gt; call, Throwable t);
  }
  </code></pre>
  
  <p>I had made class by extending retrofit callback. I want to parse the response as string. In my case  every response gets the JSON object of this type. In the case of success response:</p>
  
  <pre><code>{
    "success": true,
    "abc": {
      "a": 0.15,
      "b": "Better Exchange Rate",
    }
  }
  </code></pre>
  
  <p>In case of failure response </p>
  
  <pre><code>{
        "success": false,
        "abc": {
          "a": 0.15,
          "b": "Better Exchange Rate",
        }
      }
  </code></pre>
  
  <p>How can i convert response body into JsonObject so that i can check field <strong>"success":</strong> and navigate respective method i-e <strong>onResponseSuccess(Call call, Response response)</strong> in case of success ,<strong>onResponseFailure(Call call, Response response, String message)</strong> in case of failure</p>