Android中的Google json中的JSON字段命名支持

时间:2013-05-11 07:45:01

标签: android json gson

如何使用Google Json解析以下回复?

{
"code": 1,
"data": {
    "0": {
        "name": "test",
        "expirationDate": "-1",
        "masterDate": "31\/5\/2013",            
    },
    "message": "my message"
}
}

我试过这个....

public class Test {

public int code;
public Data data;

public class Data {
    @SerializedName("0")
    public Promo customName;
}

public class Promo {
    public String name;
    public String expirationDate;
    public String masterDate;       
}

它不起作用......帮帮我

1 个答案:

答案 0 :(得分:0)

您的Data班级缺少message变量:

public class Data {
    @SerializedName("0")
    public Promo customName;

    public String message;
}