错误解析对象并使用Gson

时间:2016-01-13 21:15:29

标签: java android json gson retrofit

我尝试了各种方法来阅读我最不成功的对象。 用Gson,babble只是java,

所有类都是Objetc的后代,为什么会发生错误。

enter image description here

public class InputDefault implements Serializable {
    private static final long serialVersionUID = 6755668336349284303L;
    private Object Result;
    private boolean Success;
    private String SuccessMessage;


public class InputGetInfosUser implements Serializable{
    private static final long serialVersionUID = 7433623152728612356L;

    @SerializedName("UserId")
    private int id;

    @SerializedName("UserName")
    private String userName;

    @SerializedName("Email")
    private String email;

    @SerializedName("Gender")
    private String gender;

    @SerializedName("LastLogin")
    private String lastLogin;


@GET("/")
public void getInfosUser(
        CancelableCallback<InputDefault> inPutCallSupportCancelableCallback
);

ERRO 1

public void sucessGetInfosUserOnListener(Object response) {
    InputDefault inputDefault = ((InputDefault) response);
    InputGetInfosUser inputGetInfosUser = null;
    String result1 = inputDefault.getResult().toString().trim();
    Gson gson = new Gson();
    inputGetInfosUser = gson.fromJson(result1, InputGetInfosUser.class); //error

值result1

enter image description here

enter image description here

ERRO 2

public void sucessGetInfosUserOnListener(Object response) {
        InputDefault inputDefault = ((InputDefault) response);
        InputGetInfosUser inputGetInfosUser = ((InputGetInfosUser) inputDefault.getResult()); //erro

enter image description here

0 个答案:

没有答案