I am trying to download a JSON for later, using the GSON library, parsing it using the respective java class Answer.class: I try to download the JSON from the link: String link=" link "; I am using the following syntax in the activity.class after establishing the connection with loopj (and verify that it connects and downloads the string properly, I also save it in a variable "link")
Respuesta funt = gson.fromJson(json, Respuesta.class);
But it seems that I do not do it correctly because the application always stops in that line of code, how should I proceed?
I attach the Respusta.class
public class Respuesta {
private int id;
private String name;
private UserBean user;
private ItemsBean items;
public int getId() {return id;}
public void setId(int id) {this.id = id;}
public String getName() {return name;}
public void setName(String name) {this.name = name;}
public UserBean getUser() {return user;}
public void setUser(UserBean user) {this.user = user;}
public ItemsBean getItems() {return items;}
public void setItems(ItemsBean items) {this.items = items;}
public static class UserBean {
private String name;
public String getName() {return name;}
public void setName(String name) {this.name = name;}
}
public static class ItemsBean {
private HashMap<String, CodigoBean> codigo;
public HashMap<String, CodigoBean> getCodigo(){return codigo;}
public void setCodigo(HashMap<String, CodigoBean> codigo) {this.codigo = codigo;}
public static class CodigoBean {
private int id;
private int strong;
private boolean active;
private String sell;
public int getId() {return id;}
public void setId(int id) {this.id = id;}
public int getStrong() {return strong;}
public void setStrong(int strong) {this.strong = strong;}
public boolean isActive() {return active;}
public void setActive(boolean active) {this.active = active;}
public String getSell() {return sell;}
public void setSell(String sell) {this.sell = sell;}
}
}}
Additional: I'm using HashMap<>
to map the codes since it can be an indeterminate number of codes besides that I would not know what they are, is it okay to use HashMap<>
that way?
Thanks in advance.