Using Retrofit2 to parse JSON in but getting NULL pointer exception & I don't know why? JSON response:
{
"query": {
"count": 1,
"created": "2016-04-29T17:19:45Z",
"lang": "US",
"results": {
"quote": [{
"name": "Talon",
"tix": "50.0000",
"avg": "34757600",
}]
}
}
}
Query class:
public class Query {
@SerializedName("query")
private String query = null;
}
Results class:
public class Results {
@SerializedName("results")
private String results = null;
@SerializedName("results")
private List<Quote> Quotes;
public List<Quote> getQuotes() {
return Quotes;
}
}
Quote class:
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;
}
}
Error returned in Android Studio logcat: java.lang.NullPointerException: storage == null at Activity.java:60. That line contains:
data = new ArrayList<>(Arrays.asList(jsonResponse.getQuotes()));
I'm not certain if the NULL is because the model classes aren't correct or something else & uncertain how/where to begin to fix it? I've looked at 4 other questions that have the same error but none were using Retrofit or JSON...