title: Retrofit 2 RxJava - Gson - "Global" deserialization, change response type
body: <p>I'm using an API which always returns JSON object that looks like this:</p>
  
  <pre><code>public class ApiResponse&lt;T&gt; {
      public boolean success;
      public T data;
  }
  </code></pre>
  
  <p><strong>data</strong> field is a JSON object that holds all valuable information. Of course it's different for different requests. So my retrofit interface looks like this:</p>
  
  <pre><code>@GET(...)
  Observable&lt;ApiResponse&lt;User&gt;&gt; getUser();
  </code></pre>
  
  <p>And when I want to handle response I need to do eg.:</p>
  
  <pre><code>response.getData().getUserId();
  </code></pre>
  
  <p>I don't really need that <strong>boolean success</strong> field and I'd like to omit it, so that my retrofit interface could look like this:</p>
  
  <pre><code>@GET(...)
  Observable&lt;User&gt; getUser();
  </code></pre>
  
  <p>Is it possible to do that in Gson? Or maybe a neat Rx function which will automatically transform this?</p>
  
  <p>EDIT:
  Example json:</p>
  
  <pre><code>{
    "success": true,
    "data": {
      "id": 22,
      "firstname": "Jon",
      "lastname": "Snow"
    }
  }
  </code></pre>
  
  <p>EDIT 2:
  I've manged to do this with retrofit interceptor where I manually modify response body. It works but if you got any other suggestions, please post them :)</p>