0

你能帮我按以下 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"
    }]
4

1 回答 1

0

这看起来像 rxkotlin 问题。我已经通过协程 kotlin 完成了它,例如:

doAsync { val groupedTransactions = accountTransactions.transactions ?.groupBy { it.effectiveDate } ....
于 2017-12-14T01:09:58.643 回答