In my Android client I receive this JSON data from a backend:
[
[
1427378400000,
553
],
[
1427382000000,
553
]
]
According to your Data, you receive a list of pair (timestamp, level). This pair is represented by a list which contains only 2 values.
So you want to emit each pair, and transform each pair into a ProductLevel
.
To do this, you'll have to flatMap
your list of pair to emit each pair. Then to map
each pair into a ProductLevel
. Finally, just build a list
with all emited items.
(java8 style)
AppObservable.bindFragment(this, responseObservable)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.flatMapIterable(listOfList -> listOfList) // or flatMap(l -> Observable.from(l))
.map(pair -> new ProductLevel(pair.get(0),pair.get(1))) // build ProductLevel for each pair
.toList() // build a list with all ProductLevel
.subscribe(listOfProductLevel -> /** ... **/);