In my Android client I receive this JSON data from a backend:
[
[
1427378400000,
553
],
[
1427382000000,
553
]
]
Here is the routine which actually loads the data. I am using RxAndroid and Retrofit here.
private void getProductLevels() {
Observable<List<List<Double>>> responseObservable =
mProductService.readProductLevels();
AppObservable.bindFragment(this, responseObservable)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
// TODO: Transform List<List<Double>> into List<ProductLevel>
.subscribe(new Subscriber<List<List<Double>>>() {
@Override
public void onCompleted() {}
@Override
public void onError(Throwable e) {}
@Override
public void onNext(List<List<Double>> response) {}
});
}
How can I map the inner List<Double>
to a specific Java class such as ProductLevel
using RxJava operators?
public class ProductLevel {
public Double mTimeStamp;
public Double mLevel;
public ProductLevel(Double timeStamp, Double level) {
mTimeStamp = timeStamp;
mLevel = level;
}
}
Finally, I would like to receive this: List<ProductLevel>
.