Witam, mam problem z pobraniem tablicy obiektów (JSON) przy użyciu RxJavy. Rzuca mi nulla ```
"asset_id_base": "USD",
"rates": [
{
"time": "2019-09-12T17:12:16.1937202Z",
"asset_id_quote": "OMG",
"rate": 0.9560157008032279813595357090
},
...
]
}
wartość "asset_id_base" udaje się pobrać natomiast przy "rates" jest ciężko
metoda GET do requesta
Call<Rates> getCryptocurrency(@Path("asset_id_base") String base);
wywołanie z RxJava gdzie w metodzie onNext chciałem również wyciągnąć obiekty z tablicy "rates"
service.getCryptocurrency("usd")
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe(new Observer<Rates>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(Rates rates) {
Log.d(TAG, "onNext: " + rates.getAsset_id_base());
}
@Override
public void onError(Throwable e) {
}
@Override
public void onComplete() {
}
});
oraz klasa Rates
public class Rates {
@SerializedName("asset_id_base")
private String asset_id_base;
@SerializedName("rates")
private List<Cryptocurrency> cryptocurrencyList;
public List<Cryptocurrency> getCryptocurrencyList() {
return cryptocurrencyList;
}
public void setCryptocurrencyList(List<Cryptocurrency> cryptocurrencyList) {
this.cryptocurrencyList = cryptocurrencyList;
}
public String getAsset_id_base() {
return asset_id_base;
}
public void setAsset_id_base(String asset_id_base) {
this.asset_id_base = asset_id_base;
}
public Rates(String asset_id_base, List<Cryptocurrency> cryptocurrencyList) {
this.asset_id_base = asset_id_base;
this.cryptocurrencyList = cryptocurrencyList;
}
}
i CryptoCurrency
public class Cryptocurrency {
private String name;
@SerializedName("time")
@Expose
private String time;
@Expose
@SerializedName("rate")
private String rate;
public String getRate() {
return rate;
}
public void setRate(String rate) {
this.rate = rate;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Cryptocurrency(String time, String rate, String name) {
this.time = time;
this.rate = rate;
this.name = name;
}
}