2

Im trying to access some list items from a json response using retrofit but cant seem to be able to access using get method. The ListQuotes seems to be saying null

@JsonPropertyOrder({
    "page",
    "last_page",
    "quotes"
})
public class ListQuoteResponse {

@JsonProperty("quotes")
private List<Quote> quotes = null;
@JsonIgnore
private Map<String, Object> additionalProperties = new HashMap<String, Object>();

/**
 * No args constructor for use in serialization
 *
 */
public ListQuoteResponse() {
}


@JsonProperty("quotes")
public List<Quote> getQuotes() {
    return quotes;
}

@JsonProperty("quotes")
public void setQuotes(List<Quote> quotes) {
    this.quotes = quotes;
}

@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
    return this.additionalProperties;
}

@JsonAnySetter
public void setAdditionalProperty(String name, Object value) {
    this.additionalProperties.put(name, value);
}

}

But when I open the Quote class I am unable to access any of the properties

public class Quote {

@JsonProperty("id")
private Integer id;
@JsonProperty("dialogue")
private Boolean dialogue;

@JsonIgnore
private Map<String, Object> additionalProperties = new HashMap<String, Object>();

/**
 * No args constructor for use in serialization
 *
 */
public Quote() {
}


@JsonProperty("id")
public Integer getId() {
    return id;
}

@JsonProperty("id")
public void setId(Integer id) {
    this.id = id;
}

@JsonProperty("dialogue")
public Boolean getDialogue() {
    return dialogue;
}

@JsonProperty("dialogue")
public void setDialogue(Boolean dialogue) {
    this.dialogue = dialogue;
}

I tried using listQuoteBodyResponse.body().getQuotes() but that only returned random numbers and when I tried using the Quote class for the response directly like QuoteResponse.body.getDialogue() its just returning null

0 Answers0