title: How to customize the response body JSON conversion in Retrofit?
body: <p>I'm using Retrofit to implement a Rest Client and I ran into some trouble when trying to convert the response body to my model Object.</p>
  
  <p>I have the following in my interface:</p>
  
  <pre><code>@POST("/users")
  void createUser(@Body RegisterUserToken token, Callback&lt;User&gt; callback);
  </code></pre>
  
  <p>My <code>User</code> class is basically a POJO with:</p>
  
  <pre><code>public class User {
  
      private int id;
      private String username;
      private String email;
      private String language;
      // getters and setters...
  }
  </code></pre>
  
  <p>And this is how I use the Rest Client:</p>
  
  <pre><code>restClient.createUser(token, new Callback&lt;User&gt;() {
      @Override
      public void success(User user, Response response) {
          // ...problem is here, with the user object
      }
  
      @Override
      public void failure(RetrofitError error) {
          // ...
      }
  });
  </code></pre>
  
  <p>The problem I'm having is that the response body is not being converted to a <code>User</code> object. I'm pretty sure the problem is that the server is returning:</p>
  
  <pre><code>{"user":{"id":13,"username":"john","email":"john@gmail.com","language":"eng"}}
  </code></pre>
  
  <p>Instead of just:</p>
  
  <pre><code>{"id":13,"username":"john","email":"john@gmail.com","language":"eng"}
  </code></pre>
  
  <p>Given that I can't really modify the server code, how can I customize Retrofit/GSON to correctly convert this response body to my User object?</p>