I'm trying to deserialize an error message I get from an api, this is my string:
{"Message":"Ya existe un usuario registrado con ese email"}
But when I call Gson like this it returns a NetworkError
with null values:
String message = new Gson().fromJson(jsonMessage, NetworkError.class).getMessage();
I have been looking at similar questions and realize there has to be something wrong in the NetworkError
class but I can't figure out what it is. Here is the class:
public class NetworkError {
private String message;
public NetworkError(final String message) {
this.message = message;
}
public String getMessage() { return message; }
}
I have tried by including a set method and an empty constructor but I still got null. Thanks