0

could you please help me to group by the following json and return a hashMap in kotlin based on date with RxKotlin? is so easy with just kotlin but really stuck for Rxkotlin. thanks

val groupedTransactions = accountTransactions.transactions ?.groupBy { it.effectiveDate }

"transactions": [{
        "id": "44e5b2bc484331ea24afd85ecfb212c8",
        "effectiveDate": "20/07/2017",
        "description": "Kaching TFR from JOHN CITIZEN<br/>xmas donation",
        "amount": 12.00
    }, {
        "id": "1506aeeb8c3a699b1e3c87db03156428",
        "effectiveDate": "20/07/2017",
        "description": "Wdl ATM CBA ATM CIRCULAR QUAY STATION NSW 221092 AUS",
        "amount": -200.00,
        "atmId": "129382"
    }, {
        "id": "9a899bfd978511e9605774e1d5222b67",
        "description": "Savings",
        "effectiveDate": "19/07/2017",
        "amount": 10.00
    }, {
        "id": "1a6c48627cecaa2388b702fa33d751ff",
        "description": "PTAG COCA COLA AMATI",
        "effectiveDate": "12/07/2017",
        "amount": -2.20
    }, {
        "id": "7ecc19e1a0be36ba2c6f05d06b5d3058",
        "description": "Wdl ATM CBA ATM TOWN HALL SQUARE NSW 253432 AUS",
        "effectiveDate": "04/07/2017",
        "amount": -50.00,
        "atmId": "137483"
    }, {
        "id": "b71bf065b640217dad602f86ac047722",
        "description": "BPAY - Telstra mobile",
        "effectiveDate": "04/07/2017",
        "amount": -49.00
    },{
        "id": "ef087651eb482bae4624478696f4ad4f",
        "description": "Transfer from REBECCA SHAW<br/>Lorem ipsum",
        "effectiveDate": "03/07/2017",
        "amount": 150.00
    }, {
        "id": "8cd283d8b7bacc277f2bae5e26ce6d1e",
        "description": "Savings",
        "effectiveDate": "01/07/2017",
        "amount": 200.00
    }, {
        "id": "04117d2d74f5331f3ee4955da27cca7a",
        "effectiveDate": "28/06/2017",
        "description": "Transfer - Saturday drinks",
        "amount": -100.00
    }, {
        "id": "821ae63dbe0c573eff8b69d451fb21bc",
        "effectiveDate": "21/06/2017",
        "description": "Wdl ATM CBA ATM CIRCULAR QUAY STATION NSW 221092 AUS",
        "amount": -200.00,
        "atmId": "129382"
    }]
  • any help would be appreciated :( – user1820178 Dec 08 '17 at 14:00
  • 1
    What have you tried so far? Why do you want to do this synchronous in-memory task with Rx? – akarnokd Dec 10 '17 at 09:11
  • Observable.fromIterable(accountTransactions.transactions) .subscribeOn(Schedulers.computation()) .observeOn(AndroidSchedulers.mainThread()) .groupBy{ it -> Transaction::effectiveDate } .subscribe({ group -> println("Key " + group.key) group.subscribe { x -> print("this is the key" + group.key.toString() + " : " + x.description) } }) – user1820178 Dec 11 '17 at 10:53
  • this looks lik the rxkotlin issue. I've done it through coroutine kotlin like: doAsync { val groupedTransactions = accountTransactions.transactions ?.groupBy { it.effectiveDate } .... – user1820178 Dec 11 '17 at 10:54
  • Welcome to Stack Overflow! Try to post code in your question; don't be afraid to edit to make it more clear what you want to do, why you want to do it, what you've already tried, and why that didn't work. – Ky - Dec 13 '17 at 23:54

1 Answers1

0

this looks lik the rxkotlin issue. I've done it through coroutine kotlin like:

doAsync { val groupedTransactions = accountTransactions.transactions ?.groupBy { it.effectiveDate } ....