Whats the best way to manipulate a Kotlin map to g...
# android
v
Whats the best way to manipulate a Kotlin map to get this result
Copy code
val k = "total"


[{"id": "123", "total": "56.00"}, {"id": "456", "total": "55.00"}]

to

map id -> k 

{"123": "56.00", "456": "55.00"}
j
listOfMaps.map { it["id"] to it[k] }.toMap()
d
listOfMaps.associate { it["id"] to it[k] }
should also work.
v
cheers guys