I have a map of string boolean pairs saved on firebase realtime database and was wondering if there is a way to retrieve it in kotlin as a linkedhashmap such that the original order remains in place.
I have tried typecasting to a linkedhashmap and got an error that hashmap cannot be typecasted to linked hashmap, I then tried calling the linkedhashmap constructor method with the parameter being the data from the database as a hashmap but that does not maintain the order
Properties in JSON are by definition not in any specific order.
While you can retrieve data from Firebase in a specific order, by calling one of its
orderBy...operations, that order will be lost when you call.valuein theDataSnapshotasDataSnapshot.valuereturns aMap, which is unordered again.If you want to retrieve the nodes in a specific order:
orderBy...to get the nodes in a specific order.childrenof the snapshot you get back to process them in order, and only callvalueon each specific child node.