I'm using Retrofit 2 and I need to handle response error in JSON format. Below is the example of the response body.
{
    "success": false,
    "error": {
        "message": {
            "name": [
                "This input is required."
            ]
        }
    }
}
message contains list of fields with errors which means the value is dynamic. Therefore, one of the possible solutions is by parsing the response body as JSON Object. I tried to get the error body using response.errorBody().string()
@Override
public void onResponse(final Call<Category> call, final Response<Category> response) {
    if (response.isSuccessful()) {
    } else {
        // Handle error
        String errorBody = response.errorBody().string();
    }
}
Unfortunately, printing the errorBody I can only get the following result
{"success":false,"error":{"message":{"name":[""]}}}
Is Retrofit limiting the errorBody object depth? What should I do to get the full response body that can be parsed?
 
     
     
    