DEV Community

Discussion on: Retrieve complex data from Firestore using Unity + Firestore SDK for your mobile app (2022)

Collapse
 
timsholenbakh profile image
Tim Sholenbakh • Edited

Hi!

I have never used the Result.ConvertTo method and I'm not sure the automatic JSON convertion works for nested data as you've shown on reddit but you can try to get the languages using the method described above and fill them in manually. The code might not be copy paste ready:

1. Iterate over your Documents:
foreach document in task.Result.Documents (inside the ContinueWithOnMainThread)
2. Convert each Document to a dictionary and get the needed value/object using the '[]' operator:
in the foreach: List<object> languages = document.ToDictionary()["languages"] as List<object>;
3. If you want to get the links from the english (en) language you need to iterate over the List<object> languages:
foreach language in languages
4. Inside this iteration, convert the language to a dictionary and get the value (the array 'links') using '[]':
List<object> links = language.ToDictionary()["links"] as List<object>;
5. Now you can iterate to get further fields :)