rxkotlin groupby无法正常工作

时间:2017-12-01 14:43:49

标签: rx-kotlin2

你可以帮我分组以下json并根据RxKotlin的日期在kotlin中返回一个hashMap吗?只是kotlin是如此容易,但真的坚持Rxkotlin。感谢

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"
    }]

1 个答案:

答案 0 :(得分:0)

这看起来像rxkotlin问题。我通过coroutine kotlin完成了它,如:

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