Tell me, how best to process a request using Retrofit 2, if it can come to the answer of a different structure?
Here is a specific example - on a POST request.
@POST("Authorization/Login") Call<Authorization> authorization(@Header("Content-Type") String contentType, @Body JSONLoginPassword jsonLoginPassword); A JSON response comes with two parameters: status and data , and if "status":"ok" , then data is a string of characters (a token, for example, "data":"xxx308f9-04xx3a-4xxxd-b6ba-89xx9c8xxxx" ). And if "status":"error" , then data for example could be such "data":{"code":"wrong-login-or-password","message":"Неверный логин или пароль"} , that is, already not a string, but a set of name: value pairs. Accordingly, if I specify one of the response structures, and another one arrives, then my authorization method falls into onFailure with the error com.google.gson.JsonSyntaxException .
Does Retrofit 2 have tools for creating an alternative response structure, and if not, how can this problem be solved?