Reputation: 37
I'm struggling to make sense of Firestore arrays in Unity/C#.
DocumentSnapshot snap = task.Result;
IDictionary<string, object> dict = snap.ToDictionary();
object questData = dict["questData"];
How do I say results = dict["questData"][0].results?
Debugger shows questData as object I can't figure out how to say: object[] questData = dict["questData"]
It comes in from Firestore as an object but it's really an array.
Upvotes: 0
Views: 1171
Reputation: 17007
i dont see if its array or list oe IEnumerable..
but you could use that to unbox object:
var x =dict["quesData"] as object[] or List<object>
and following the type you apply the same schema.
if collection (ict["questData"]) is dictionary you could apply that:
foreach (KeyValuePair<string, object> pair in dict["questData"])
{
Console.WriteLine("{0}: {1}", pair.Key, pair.Value);
}
to find the other keys, i dont see if key is string, so object should does the job in case...
so you could write too: var x =dict["quesData"] as Dictionary<string, object>
Upvotes: 1