I'm using Retrofit in my Android app to query my [aREST server](https://github.com/marcoschwartz/aREST), which returns:

```
{"return_value": 1, "id": "1", "name": "esp8266", "connected": true}

```

This is my Api response POJO

**ApiResponse.java**

```
public class ApiResponse {

  private String id;
  private String name;
  private boolean connected;

  @SerializedName("return_value")
  private int returnValue;

  private boolean isReturnValueSet = false;

  public String getId() {
    return id;
  }

  ...

  public int getReturnValue() {
    return returnValue;
  }

  public void setReturnValue(int returnValue) {
    Log.v("ZetaRemote", "ApiResponse.setReturnValue");
    this.returnValue = returnValue;
    this.isReturnValueSet = true;
  }

  public String toString() {
    // {"id": "1", "name": "esp8266", "connected": true}
    String result;
    String base = "\"id\": \"" + id + "\", \"name\": \"" + name + "\", \"connected\": " + connected;

    String extra = null;
    if (message != null) result = "\"message\": " + message + " " + base;
    else if (isReturnValueSet) result = "\"return_value\": " + returnValue + " " + base;
    else result = base;

    return "{" + result + "}";
  }
}

```

I tried to use `SerializedName` and Log to see if `setReturnValue` is triggered but nothing.

This is pidcat log with retrofit debug messages enabled:

```
D  Command image clicked
D  ApiClient.setServer(192.168.1.20)
D  ApiClient.getMyApiClient
D  ---> HTTP GET http://192.168.1.20/led?params=750
D  ---> END HTTP (no body)
D  <--- HTTP 200 http://192.168.1.20/led?params=750 (215ms)
D  Access-Control-Allow-Origin: *
D  Access-Control-Allow-Methods: POST, GET, PUT, OPTIONS
D  Content-Type: application/json
D  Connection: close
D  OkHttp-Selected-Protocol: http/1.1
D  OkHttp-Sent-Millis: 1443122723645
D  OkHttp-Received-Millis: 1443122723754
D  {"return_value": 1, "id": "1", "name": "esp8266", "connected": true}
D  <--- END HTTP (70-byte body)
D  Success, response: {"id": "1", "name": "esp8266", "connected": true}

```

What should I change in order to successfully get `return_value`?

**Solution thanks to iagreen's answer**

```
ApiResponse.java

public class ApiResponse {

  private String id;
  private String name;
  private boolean connected;

  private String message;

  @SerializedName("return_value")
  private Integer returnValue;

  public String getId() {
    return id;
  }

  ...

  public Integer getReturnValue() {
    return returnValue;
  }

  public void setReturnValue(Integer returnValue) {
    this.returnValue = returnValue;
  }

  public String toString() {
    // {"id": "1", "name": "esp8266", "connected": true}
    String result;
    String base = "\"id\": \"" + id + "\", \"name\": \"" + name + "\", \"connected\": " + connected;

    String extra = null;
    if (message != null) result = "\"message\": " + message + ", " + base;
    else if (returnValue != null) result = "\"return_value\": " + returnValue + ", " + base;
    else result = base;

    return "{" + result + "}";
  }
}

```

As iagreen pointed out, I was just hiding `return_value` in my poorly written `toString()` method. Using `Integer` instead of `int` allows me to check if it exists and therefore correctly build my `toString()` method.

Thanks for the `StringBuilder` suggestion, I'll take a look at it.