Парсю API сайта
https://api.qrfinex.com/v1.1/actions
вот так выглядит json
Получаю данные вот так
public static void main(String[] args) throws ParserConfigurationException, IOException, SAXException {
ArrayList<String> xmlArrayList = new ArrayList<String>();
URL url;
URLConnection uc;
StringBuilder parsedContentFromUrl = new StringBuilder();
String urlString = "https://api.qrfinex.com/v1.1/actions";
System.out.println("Getting content for URl : " + urlString);
url = new URL(urlString);
uc = url.openConnection();
uc.connect();
uc = url.openConnection();
uc.addRequestProperty("User-Agent",
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");
uc.getInputStream();
BufferedReader in = new BufferedReader(new InputStreamReader(uc.getInputStream(), "UTF-8"));
int ch;
while ((ch = in.read()) != -1) {
parsedContentFromUrl.append((char) ch);
}
System.out.println(parsedContentFromUrl);
// получаем данные из сайта
//==========================================================================
// преобразуем полученные данные
Gson gson = new Gson();
RootObject response = gson.fromJson(String.valueOf(parsedContentFromUrl), RootObject.class);
System.out.println(response.getActions());
А вот тут классы, которые принимают, но выводят null
public class Provider {
private int id;
private String name;
private String icon;
private String web;
private String ios;
private String android;
@JsonProperty("id")
public int getId() {
return id;
}
@JsonProperty("id")
public void setId(int id) {
this.id = id;
}
@JsonProperty("name")
public String getName() {
return name;
}
@JsonProperty("name")
public void setName(String name) {
this.name = name;
}
@JsonProperty("icon")
public String getIcon() {
return icon;
}
@JsonProperty("icon")
public void setIcon(String icon) {
this.icon = icon;
}
@JsonProperty("web")
public String getWeb() {
return web;
}
@JsonProperty("web")
public void setWeb(String web) {
this.web = web;
}
@JsonProperty("ios")
public String getIos() {
return ios;
}
@JsonProperty("ios")
public void setIos(String ios) {
this.ios = ios;
}
@JsonProperty("android")
public String getAndroid() {
return android;
}
@JsonProperty("android")
public void setAndroid(String android) {
this.android = android;
}
}
public class RootObject {
private Provider[] providers;
private Actions actions;
@JsonProperty("providers")
public Provider[] getProviders() {
return providers;
}
@JsonProperty("providers")
public void setProviders(Provider[] providers) {
this.providers = providers;
}
@JsonProperty("actions")
public Actions getActions() {
return actions;
}
@JsonProperty("actions")
public void setActions(Actions actions) {
this.actions = actions;
}
}
Может быть я неправильно сделал классы?