Getting simple JSON object response using Retrofit library
Simply use JsonElement
insted of JSONobject
. Like:
@GET("/stockers/login")
Call<JsonElement> getLogin(
@Query("email") String email,
@Query("password") String password
);
Instead of Callback with JSONObject class, you could use the Retrofit basic callback which use the Response class and then, once you get the response, you had to create the JSONObject from it.
See this: https://stackoverflow.com/a/30870326/2037304
Otherwise you can create your own model class to handle the response.
First the Result class:
public class Result {
public int id;
public String name;
public String email;
public String password;
public boolean status;
public Date created;
}
And then your response class to use with Retrofit
public class MyResponse {
public boolean status;
public Result result;
public String message;
}
Now you can call:
@GET("/stockers/login")
public void login(
@Query("email") String email,
@Query("password") String password,
Callback<MyResponse> callback);