Retrofit2 java.lang.NullPointerException:storage == null

时间:2016-05-02 16:25:31

标签: java android json gson retrofit2

使用Retrofit2解析JSON,但获得NULL指针异常&我不知道为什么? JSON响应:

{
"query": {
    "count": 1,
    "created": "2016-04-29T17:19:45Z",
    "lang": "US",
    "results": {
        "quote": [{
            "name": "Talon",
            "tix": "50.0000",
            "avg": "34757600",
                 }]
              }
        }
}

查询类:

public class Query {

@SerializedName("query")
private String query = null;

}

结果类:

public class Results {

@SerializedName("results")
private String results = null;

@SerializedName("results")
private List<Quote> Quotes;
public List<Quote> getQuotes() {
    return Quotes;
}
}

引用类:

public class Quote {

@SerializedName("name")
private String Name;
public String getName() {
    return Name;
}

@SerializedName("tix")
private String Tix;
public String getTix() {
    return Tix;
}

@SerializedName("avg")
private String Avg;
public String getAvg() {
    return Avg;
}

}

Android Studio logcat中返回错误:java.lang.NullPointerException:存储== null,位于Activity.java:60。该行包含:

data = new ArrayList<>(Arrays.asList(jsonResponse.getQuotes()));

我不确定NULL是否是因为模型类不正确或其他东西&amp;不确定如何/从哪里开始修复它?我已经查看了其他4个具有相同错误但没有使用Retrofit或JSON的问题...

0 个答案:

没有答案