I have a database where I retrieve data from and store it in a Map<String, Any> collection.
It looks something like this when printed in a Log:
{-MxY_3dqegF7YmP-NEaE8={Factors={Percentage=52.89, Got Stuff=0, Happy=1}, Result=Ok, Probability=50}}
This looks fine, in Python I would know how to go about it as it would be like a dictionary, but the problem is the inner keys and values are of this Any type object in Kotlin.
I am unable to work with that type and iterate through the keys and lists. I can only print the data as a String but that's all I know:
val values = snapshot.getValue<Map<String, Any>>()
Log.d("[CLIENT]", "Value is: $values")
var keys = mutableListOf<String>()
var data = mutableListOf<Any>()
if (values != null) {
for ((k, v) in values) {
keys.add(k)
}
}
val check = values?.get(keys[0])
Log.d("[CLIENT]", "Key is: $check")
It would print check like this:
{Factors={Percentage=52.89, Got Stuff=0, Happy=1}, Result=Ok, Probability=50}
check is of type Any?, so how do I convert it or use it like a Map, or any other simpler way, similar to like maybe Python Dictionaries?