<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Tim Sholenbakh</title>
    <description>The latest articles on DEV Community by Tim Sholenbakh (@timsholenbakh).</description>
    <link>https://dev.to/timsholenbakh</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F839315%2F47d705dc-9be6-445a-9337-7bffc821f2f0.jpg</url>
      <title>DEV Community: Tim Sholenbakh</title>
      <link>https://dev.to/timsholenbakh</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/timsholenbakh"/>
    <language>en</language>
    <item>
      <title>Retrieve complex data from Firestore using Unity + Firestore SDK for your mobile app (2022)</title>
      <dc:creator>Tim Sholenbakh</dc:creator>
      <pubDate>Wed, 30 Mar 2022 18:56:16 +0000</pubDate>
      <link>https://dev.to/timsholenbakh/retrieve-complex-data-from-firestore-using-unity-firestore-sdk-for-your-mobile-app-2022-4gnc</link>
      <guid>https://dev.to/timsholenbakh/retrieve-complex-data-from-firestore-using-unity-firestore-sdk-for-your-mobile-app-2022-4gnc</guid>
      <description>&lt;p&gt;Hi! In this article I'd like to show you a simple way to get started with retrieving any type of data from Firestore in Unity using the Firestore Package for your mobile app. At the time of writing this article there's no JSON support yet.&lt;br&gt;
The shown method is quite straightforward and does &lt;strong&gt;&lt;u&gt;not&lt;/u&gt;&lt;/strong&gt; involve writing our own JSON converters.&lt;/p&gt;

&lt;p&gt;⚠️ = Be aware&lt;br&gt;
⏬ = Download&lt;/p&gt;

&lt;h3&gt;
  
  
  Table of contents:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Requirements&lt;/li&gt;
&lt;li&gt;Preparation&lt;/li&gt;
&lt;li&gt;Adding Data&lt;/li&gt;
&lt;li&gt;Retrieving Data&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;⚠️ In this tutorial there will be code snippets from my Painting Recognition app. There's no available code repository &lt;strong&gt;&lt;u&gt;yet&lt;/u&gt;&lt;/strong&gt; since this app is a schoolproject on which my grades are dependent.&lt;/p&gt;




&lt;h3&gt;
  
  
  Requirements &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;In this demo we'll be using:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;⏬ &lt;a href="https://unity3d.com/get-unity/download" rel="noopener noreferrer"&gt;Unity Hub (Personal License) -&amp;gt; Unity 2020.3.26f1&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Modules (2): Android &amp;amp; iOS Build Support&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;&lt;p&gt;⏬ &lt;a href="https://firebase.google.com/download/unity" rel="noopener noreferrer"&gt;Firebase Unity SDK 8.8.0&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;&lt;a href="https://console.firebase.google.com" rel="noopener noreferrer"&gt;Firebase Console&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  Preparation
&lt;/h3&gt;

&lt;p&gt;(If you have already &lt;strong&gt;done these steps&lt;/strong&gt;, go to Adding Data or Retrieving Data)&lt;/p&gt;

&lt;p&gt;Here's what you need to do to set it all up!&lt;/p&gt;

&lt;h4&gt;
  
  
  1. Create/Use an Unity project
&lt;/h4&gt;

&lt;p&gt;Tutorial link &lt;a href="https://www.youtube.com/watch?v=mcHBN_mDIxI" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  2. Add Firebase to your Unity project
&lt;/h4&gt;

&lt;p&gt;Tutorial link &lt;a href="https://firebase.google.com/docs/unity/setup" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;⚠️ Be sure to enter a &lt;code&gt;Package Name&lt;/code&gt; for your app since you'll have to use this later!&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnlg9814195v3ds17rzgz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnlg9814195v3ds17rzgz.png" alt="Firebase App Management"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  3. Link Firebase with Unity
&lt;/h4&gt;

&lt;p&gt;Once you've filled in your &lt;code&gt;Package Name&lt;/code&gt; you can now do the same in your &lt;strong&gt;Unity project&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Go to 'File' -&amp;gt; 'Build Settings' &lt;/li&gt;
&lt;li&gt;Select your &lt;code&gt;Platform&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Once selected, click on &lt;code&gt;Player Settings&lt;/code&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F587lncv8iok3pluuvzmu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F587lncv8iok3pluuvzmu.png" alt="Player Settings"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Scroll down until you find &lt;code&gt;Bundle Identifier&lt;/code&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgye4oygolx6fzo7k589g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgye4oygolx6fzo7k589g.png" alt="Bundle Identifier"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter the &lt;strong&gt;same&lt;/strong&gt; &lt;code&gt;Package Name&lt;/code&gt; you've chosen&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Next add the Firebase SDK:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Extract the &lt;code&gt;.zip&lt;/code&gt; SDK&lt;/li&gt;
&lt;li&gt;Go into the folder &lt;code&gt;dotnet4&lt;/code&gt; since our Unity version is &amp;gt; 2017&lt;/li&gt;
&lt;li&gt;Go back to Unity and create and open the folder 'Firebase' in 'Assets'&lt;/li&gt;
&lt;li&gt;Drag and drop the &lt;code&gt;FirebaseFirestore.unitypackage&lt;/code&gt; in the 'Firebase' folder (to keep it organised)&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;Finally, download the &lt;code&gt;Project Identifier&lt;/code&gt; file from the &lt;a href="https://console.firebase.google.com" rel="noopener noreferrer"&gt;Firebase Console&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Android: ⏬ &lt;code&gt;google-services.json&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;iOS: ⏬ &lt;code&gt;GoogleService-Info.plist&lt;/code&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsez25fxfgm32lc6koxw2.png" alt="google-services file"&gt;
&lt;/li&gt;
&lt;li&gt;Drop this file into the 'Assets' folder in Unity&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  Adding Data &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Before we can retrieve any data we need to add it first. Be advised to structure your to be retrieved data beforehand. It might save you a lot of time rewriting code!&lt;/p&gt;

&lt;p&gt;Firestore is a non-relational (a.k.a. &lt;strong&gt;NoSQL&lt;/strong&gt;) database like MongoDB. There are no columns, no specific order and no foreign keys to create any type of relationship with other data. In Firestore or other NoSQL databases, data is stored in a &lt;code&gt;Collection&lt;/code&gt; of &lt;code&gt;Documents&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;In this example the data will be structured the following way:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffbo2pvizc63z1n03nbzu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffbo2pvizc63z1n03nbzu.png" alt="Data Structure"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Above is a list of paintings (known as a &lt;code&gt;Collection&lt;/code&gt;) wherein each individual painting (known as a &lt;code&gt;Document&lt;/code&gt;) resides.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Each document also has its own &lt;code&gt;fields&lt;/code&gt;. This is the actual data that belongs to that document.&lt;/p&gt;

&lt;p&gt;In this example, the document fields look schematically like this:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv49n2k4rr4nh4yib7vn6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv49n2k4rr4nh4yib7vn6.png" alt="Document Scheme"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Each painting has a couple of points of interest and each point has multiple descriptions for the different languages that they can be read in.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In Firestore it will look hierarchical:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpvabjzo1mvdrabjq4a22.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpvabjzo1mvdrabjq4a22.png" alt="Hierarchical structure"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now it's up to you! &lt;strong&gt;Add data&lt;/strong&gt; to your Firestore. You can do this manually or through code. If you'd like have more information on structures and how to add data, take a look on the &lt;a href="https://firebase.google.com/docs/firestore/manage-data/add-data" rel="noopener noreferrer"&gt;Firestore Documentation: Add Data&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Retrieving Data &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Now onto the fun part: &lt;code&gt;&amp;lt;coding&amp;gt;&lt;/code&gt; :)! In Unity, add an empty &lt;code&gt;GameObject&lt;/code&gt; in the hierarchy and create a new script in &lt;code&gt;Assets &amp;gt; Scripts&lt;/code&gt;. Attach this script as a component on the cube and open this script in your favorite editor (I use JetBrains Rider).&lt;br&gt;
It should look like this:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fukj4773xadyuc246wyyw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fukj4773xadyuc246wyyw.png" alt="Inspector Add Component"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Reference to Firebase
&lt;/h4&gt;

&lt;p&gt;First we need to get a reference to our collection (fill in your collection name): &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

private Task&amp;lt;QuerySnapshot&amp;gt; _storageSnapshot;
void Awake() =&amp;gt; _storageSnapshot = FirebaseFirestore.DefaultInstance.Collection("Paintings").GetSnapshotAsync();


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;We don't have to worry about opening or closing connections. The code will do its magic by checking our &lt;code&gt;Project Identifier&lt;/code&gt; and &lt;code&gt;Package Name&lt;/code&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Coroutines
&lt;/h4&gt;

&lt;p&gt;Next we'll write a coroutine. This method is identified by returning an IEnumerator. Coroutines work like void methods in terms of returning nothing really. To make it work, we add a method as a parameter (also known as a callback) to which we give our result to. In this case it's a list of our retrieved paintings.&lt;/p&gt;

&lt;p&gt;A coroutine is Unity's way of handling asynchronous operations and multithreading. We can start iterating on the retrieved collection by creating an anonymous method to continue the Task:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

public IEnumerator GetPaintingsAndPois(Action&amp;lt;IList&amp;lt;Painting&amp;gt;&amp;gt; callback)
{
     IList&amp;lt;Painting&amp;gt; paintingList = new List&amp;lt;Painting&amp;gt;();
     int paintingCount = 0;
     _storageSnapshot.ContinueWithOnMainThread(task =&amp;gt;
     {
          var collection = task.Result;
          if (collection.Count == 0)
              Debug.LogError("There are no paintings available in the collection 'Paintings'.");

          paintingCount = collection.Count;
          Debug.Log("Found " + paintingCount + " paintings!");
     }
     yield return new WaitUntil(() =&amp;gt; paintingList.Count == 
     paintingCount &amp;amp;&amp;amp; paintingList.Count != 0);
     Debug.Log("Done getting " + paintingCount + " paintings!");
     callback(paintingList);
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;With coroutines you can stop execution until a certain predicate is met. In this example I wait until it has retrieved all the paintings. Due to the synchronous way of how the paintings are retrieved (no async/await keywords), the &lt;code&gt;WaitUntil()&lt;/code&gt; is very important. I have tried using async/await but I ran into order of execution and threading issues. As said previously, coroutines handle this for you. &lt;/p&gt;

&lt;p&gt;At this stage, we've gotten all our paintings but did nothing with them. Let's take a look on how to iterate over them.&lt;/p&gt;

&lt;p&gt;(If you'd like to see the boilerplate code for this, you can visit the &lt;a href="https://firebase.google.com/docs/firestore/query-data/get-data" rel="noopener noreferrer"&gt;Firestore Documentation: Get Data&lt;/a&gt;)&lt;/p&gt;

&lt;h4&gt;
  
  
  Dictionaries
&lt;/h4&gt;

&lt;p&gt;Since there's no JSON support, we have to make it work the cumbersome way with dictionaries. Dictionaries in particular are very useful for combining data into &lt;code&gt;Key-Value Pairs&lt;/code&gt;. In our case it's going to be matching a string (name of the key) to an object (fields from a Document). &lt;code&gt;Value&lt;/code&gt; is an object so we can cast it to any type we need.&lt;/p&gt;

&lt;p&gt;Let's start with unstructured, easy to access data like the painting's title. For this we need to loop over each &lt;code&gt;Document&lt;/code&gt; in our retrieved collection:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

//...
//paintingCount = collection.Count;
//Debug.Log("Found " + paintingCount + " paintings!");

foreach (var paintingData in collection.Documents)
{
      string titlePainting = ???
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;To retrieve a &lt;code&gt;Value&lt;/code&gt; from a dictionary, you can use the &lt;code&gt;[]&lt;/code&gt; operator. In code it will look like this:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

paintingData.ToDictionary()["title"]


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This will give you the &lt;code&gt;Value&lt;/code&gt; for the key "title". Using this method we can now loop over each painting/document and get our &lt;code&gt;field&lt;/code&gt; by safe casting it (&lt;a href="https://stackoverflow.com/a/7566234" rel="noopener noreferrer"&gt;using 'as'&lt;/a&gt;) to the right type at the end:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

foreach (var paintingData in collection.Documents)
{
      string titlePainting = paintingData.ToDictionary()["title"] as string
      //string painter = ...
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h4&gt;
  
  
  Retrieving an array
&lt;/h4&gt;

&lt;p&gt;Now we can apply this method to every other &lt;code&gt;field&lt;/code&gt; &lt;em&gt;except&lt;/em&gt; to an array. Let's say we want to retrieve the &lt;code&gt;PointsOfInterest[]&lt;/code&gt; array from our painting.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc2z079mbqsq3b0jqw3vv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc2z079mbqsq3b0jqw3vv.png" alt="POI Structure"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You might think we can apply the same technique using &lt;code&gt;[]&lt;/code&gt; on the dictionary and then safe cast it to object[] but it will result in a &lt;code&gt;NullPointerException&lt;/code&gt;. It goes against intuition since it is an array in Firestore.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fewowsbhas1tsu49dr6re.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fewowsbhas1tsu49dr6re.png" alt="Array Firestore"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What does work however is safe casting it to &lt;code&gt;List&amp;lt;object&amp;gt;&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

List&amp;lt;object&amp;gt; pointsOfInterest = painting.ToDictionary()["pois"] as List&amp;lt;object&amp;gt;;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h4&gt;
  
  
  Retrieving nested arrays
&lt;/h4&gt;

&lt;p&gt;Now we've covered how to get an array out of a &lt;code&gt;Document&lt;/code&gt; but... how do we get an array out of an array you might ask. Luckily the answer is somewhat the same.&lt;/p&gt;

&lt;p&gt;Since we have a &lt;code&gt;List&amp;lt;PointsOfInterest&amp;gt;&lt;/code&gt; we can iterate it and safe cast our object to a &lt;code&gt;Dictionary&amp;lt;string, object&amp;gt;&lt;/code&gt; to be able to retrieve data from it:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

foreach (object poi in pointsOfInterest)
{
      Dictionary&amp;lt;string, object&amp;gt; poiDictionary = poi as Dictionary&amp;lt;string, object&amp;gt;;
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;And now you can simply use &lt;code&gt;[]&lt;/code&gt; to get the descriptions and safe cast them to a &lt;code&gt;List&amp;lt;object&amp;gt;&lt;/code&gt;:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F04tn98yhjwqjplicurg2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F04tn98yhjwqjplicurg2.png" alt="Descriptions"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

foreach (object poi in pointsOfInterest)
{
      Dictionary&amp;lt;string, object&amp;gt; poiDictionary = poi as Dictionary&amp;lt;string, object&amp;gt;;

      //Another array...
      List&amp;lt;Description&amp;gt; = poiDictionary["descriptions"] as List&amp;lt;object&amp;gt;;
      //string language ...
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h4&gt;
  
  
  Result
&lt;/h4&gt;

&lt;p&gt;Everything combined, the coroutine's structure should look similar to this:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

public IEnumerator GetPaintingsAndPois(Action&amp;lt;IList&amp;lt;Painting&amp;gt;&amp;gt; callback)
{
  //...
  _storageSnapshot.ContinueWithOnMainThread(task =&amp;gt;
  {
    var collection = task.Result;
    foreach (var paintingData in collection.Documents)
    {
      string titlePainting = paintingData.ToDictionary()["title"] as string
      //string painter = ...

      List&amp;lt;object&amp;gt; pointsOfInterest = painting.ToDictionary()["pois"] as List&amp;lt;object&amp;gt;;
      foreach (object poi in pointsOfInterest)
      {
        Dictionary&amp;lt;string, object&amp;gt; poiDictionary = poi as Dictionary&amp;lt;string, object&amp;gt;;
        List&amp;lt;Description&amp;gt; = poiDictionary["descriptions"] as List&amp;lt;object&amp;gt;;
        //string language...
      }
    }
  }
  //...
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;And that's it! You've successfully gotten all the fields you needed. Now you can work on the more &lt;em&gt;fun&lt;/em&gt; things in your app.&lt;/p&gt;

&lt;p&gt;If you have any issues, feel free to let me know down below in the comments :)!&lt;/p&gt;

</description>
      <category>unity3d</category>
      <category>firebase</category>
      <category>arrays</category>
      <category>android</category>
    </item>
  </channel>
</rss>
