Array of dictionaries with Unity and Firebase database - Get values from key












0















First of all - I am pretty new to Unity.



I am trying to retrieve some data from my firebase database, store the data in an array/list of dictionaries, and then use the array/list to show the data from my server.



So... My way of trying to do:



1: Create array of dictionaries to hold my data:



[System.Serializable]
public class Global
{
public static Dictionary<string, object> offers;
}


2: Handle the data from the database, and store it in the array:



void Handle_ChildAdded(object sender, ChildChangedEventArgs e)
{
if (e.DatabaseError != null)
{
Debug.LogError(e.DatabaseError.Message);
return;
}
// Do something with the data in args.Snapshot
if (e.Snapshot.Value != null)
{
var dict = e.Snapshot.Value as Dictionary<string, object>;

if (dict != null)
{
Debug.Log(dict);
Global.offers = new Dictionary<string, object>[Global.storesCount+1];
Global.offers[Global.storesCount] = dict;
Global.storesCount++;
hasHaded = true;
}
}
}


So now I have alle the snapshots from my database in my Global.offers array. The struckture of the snapshot i should get look something likes this:
enter image description here



Time to show the data from my array



Everything works fine until this point - Because now I need to show the data I just stored in my Global.offers array.
I try to do that with a loop. I loop though the array and search for the keys from my database and Instantiate the data inside a prefab of a gameobject like this:



 for (int i = 0; i < Global.storesCount; i++)
{
Transform scrollViewObj = Instantiate(prefab, new Vector3(0, (downSize * i) - firstY, 0), Quaternion.identity);
scrollViewObj.transform.SetParent(scrollContent.transform, false);
scrollViewObj.transform.Find("Overskift").gameObject.GetComponent<Text>().text = Global.offers[i]["Store"] as string;
scrollViewObj.transform.Find("Text (1)").gameObject.GetComponent<Text>().text = Global.offers[i]["Headline"] as string;
scrollViewObj.transform.Find("Text (2)").gameObject.GetComponent<Text>().text = "Din pris: " + Global.offers[i]["Price"] as string + " kr.";
scrollViewObj.transform.Find("Text (3)").gameObject.GetComponent<Text>().text = "Spar: " + Global.offers[i]["AndresPris"] as string + " kr.";
}


This is where I get the trouble. For some reason Global.offers[i]["Store"] as string == null, witch of course means that I can't instantiate the object. I get this error:



NullReferenceException: Object reference not set to an instance of an object
LoadOffers.Start () (at Assets/Scripts/LoadOffers.cs:36)



It is so weird, because when I try to debug I get some conflicting results:



The length of the array is 19. So it is not empty.



When I try to Debug.Log the array out I get:



System.Collections.Generic.Dictionary`2[System.String,System.Object]



But when I search for values with keys like:



Debug.Log(Global.offers[0]["Store"]);


All I get is null. Am I searching wrong after the values? Or can anyone else see what I am doing wrong?










share|improve this question





























    0















    First of all - I am pretty new to Unity.



    I am trying to retrieve some data from my firebase database, store the data in an array/list of dictionaries, and then use the array/list to show the data from my server.



    So... My way of trying to do:



    1: Create array of dictionaries to hold my data:



    [System.Serializable]
    public class Global
    {
    public static Dictionary<string, object> offers;
    }


    2: Handle the data from the database, and store it in the array:



    void Handle_ChildAdded(object sender, ChildChangedEventArgs e)
    {
    if (e.DatabaseError != null)
    {
    Debug.LogError(e.DatabaseError.Message);
    return;
    }
    // Do something with the data in args.Snapshot
    if (e.Snapshot.Value != null)
    {
    var dict = e.Snapshot.Value as Dictionary<string, object>;

    if (dict != null)
    {
    Debug.Log(dict);
    Global.offers = new Dictionary<string, object>[Global.storesCount+1];
    Global.offers[Global.storesCount] = dict;
    Global.storesCount++;
    hasHaded = true;
    }
    }
    }


    So now I have alle the snapshots from my database in my Global.offers array. The struckture of the snapshot i should get look something likes this:
    enter image description here



    Time to show the data from my array



    Everything works fine until this point - Because now I need to show the data I just stored in my Global.offers array.
    I try to do that with a loop. I loop though the array and search for the keys from my database and Instantiate the data inside a prefab of a gameobject like this:



     for (int i = 0; i < Global.storesCount; i++)
    {
    Transform scrollViewObj = Instantiate(prefab, new Vector3(0, (downSize * i) - firstY, 0), Quaternion.identity);
    scrollViewObj.transform.SetParent(scrollContent.transform, false);
    scrollViewObj.transform.Find("Overskift").gameObject.GetComponent<Text>().text = Global.offers[i]["Store"] as string;
    scrollViewObj.transform.Find("Text (1)").gameObject.GetComponent<Text>().text = Global.offers[i]["Headline"] as string;
    scrollViewObj.transform.Find("Text (2)").gameObject.GetComponent<Text>().text = "Din pris: " + Global.offers[i]["Price"] as string + " kr.";
    scrollViewObj.transform.Find("Text (3)").gameObject.GetComponent<Text>().text = "Spar: " + Global.offers[i]["AndresPris"] as string + " kr.";
    }


    This is where I get the trouble. For some reason Global.offers[i]["Store"] as string == null, witch of course means that I can't instantiate the object. I get this error:



    NullReferenceException: Object reference not set to an instance of an object
    LoadOffers.Start () (at Assets/Scripts/LoadOffers.cs:36)



    It is so weird, because when I try to debug I get some conflicting results:



    The length of the array is 19. So it is not empty.



    When I try to Debug.Log the array out I get:



    System.Collections.Generic.Dictionary`2[System.String,System.Object]



    But when I search for values with keys like:



    Debug.Log(Global.offers[0]["Store"]);


    All I get is null. Am I searching wrong after the values? Or can anyone else see what I am doing wrong?










    share|improve this question



























      0












      0








      0








      First of all - I am pretty new to Unity.



      I am trying to retrieve some data from my firebase database, store the data in an array/list of dictionaries, and then use the array/list to show the data from my server.



      So... My way of trying to do:



      1: Create array of dictionaries to hold my data:



      [System.Serializable]
      public class Global
      {
      public static Dictionary<string, object> offers;
      }


      2: Handle the data from the database, and store it in the array:



      void Handle_ChildAdded(object sender, ChildChangedEventArgs e)
      {
      if (e.DatabaseError != null)
      {
      Debug.LogError(e.DatabaseError.Message);
      return;
      }
      // Do something with the data in args.Snapshot
      if (e.Snapshot.Value != null)
      {
      var dict = e.Snapshot.Value as Dictionary<string, object>;

      if (dict != null)
      {
      Debug.Log(dict);
      Global.offers = new Dictionary<string, object>[Global.storesCount+1];
      Global.offers[Global.storesCount] = dict;
      Global.storesCount++;
      hasHaded = true;
      }
      }
      }


      So now I have alle the snapshots from my database in my Global.offers array. The struckture of the snapshot i should get look something likes this:
      enter image description here



      Time to show the data from my array



      Everything works fine until this point - Because now I need to show the data I just stored in my Global.offers array.
      I try to do that with a loop. I loop though the array and search for the keys from my database and Instantiate the data inside a prefab of a gameobject like this:



       for (int i = 0; i < Global.storesCount; i++)
      {
      Transform scrollViewObj = Instantiate(prefab, new Vector3(0, (downSize * i) - firstY, 0), Quaternion.identity);
      scrollViewObj.transform.SetParent(scrollContent.transform, false);
      scrollViewObj.transform.Find("Overskift").gameObject.GetComponent<Text>().text = Global.offers[i]["Store"] as string;
      scrollViewObj.transform.Find("Text (1)").gameObject.GetComponent<Text>().text = Global.offers[i]["Headline"] as string;
      scrollViewObj.transform.Find("Text (2)").gameObject.GetComponent<Text>().text = "Din pris: " + Global.offers[i]["Price"] as string + " kr.";
      scrollViewObj.transform.Find("Text (3)").gameObject.GetComponent<Text>().text = "Spar: " + Global.offers[i]["AndresPris"] as string + " kr.";
      }


      This is where I get the trouble. For some reason Global.offers[i]["Store"] as string == null, witch of course means that I can't instantiate the object. I get this error:



      NullReferenceException: Object reference not set to an instance of an object
      LoadOffers.Start () (at Assets/Scripts/LoadOffers.cs:36)



      It is so weird, because when I try to debug I get some conflicting results:



      The length of the array is 19. So it is not empty.



      When I try to Debug.Log the array out I get:



      System.Collections.Generic.Dictionary`2[System.String,System.Object]



      But when I search for values with keys like:



      Debug.Log(Global.offers[0]["Store"]);


      All I get is null. Am I searching wrong after the values? Or can anyone else see what I am doing wrong?










      share|improve this question
















      First of all - I am pretty new to Unity.



      I am trying to retrieve some data from my firebase database, store the data in an array/list of dictionaries, and then use the array/list to show the data from my server.



      So... My way of trying to do:



      1: Create array of dictionaries to hold my data:



      [System.Serializable]
      public class Global
      {
      public static Dictionary<string, object> offers;
      }


      2: Handle the data from the database, and store it in the array:



      void Handle_ChildAdded(object sender, ChildChangedEventArgs e)
      {
      if (e.DatabaseError != null)
      {
      Debug.LogError(e.DatabaseError.Message);
      return;
      }
      // Do something with the data in args.Snapshot
      if (e.Snapshot.Value != null)
      {
      var dict = e.Snapshot.Value as Dictionary<string, object>;

      if (dict != null)
      {
      Debug.Log(dict);
      Global.offers = new Dictionary<string, object>[Global.storesCount+1];
      Global.offers[Global.storesCount] = dict;
      Global.storesCount++;
      hasHaded = true;
      }
      }
      }


      So now I have alle the snapshots from my database in my Global.offers array. The struckture of the snapshot i should get look something likes this:
      enter image description here



      Time to show the data from my array



      Everything works fine until this point - Because now I need to show the data I just stored in my Global.offers array.
      I try to do that with a loop. I loop though the array and search for the keys from my database and Instantiate the data inside a prefab of a gameobject like this:



       for (int i = 0; i < Global.storesCount; i++)
      {
      Transform scrollViewObj = Instantiate(prefab, new Vector3(0, (downSize * i) - firstY, 0), Quaternion.identity);
      scrollViewObj.transform.SetParent(scrollContent.transform, false);
      scrollViewObj.transform.Find("Overskift").gameObject.GetComponent<Text>().text = Global.offers[i]["Store"] as string;
      scrollViewObj.transform.Find("Text (1)").gameObject.GetComponent<Text>().text = Global.offers[i]["Headline"] as string;
      scrollViewObj.transform.Find("Text (2)").gameObject.GetComponent<Text>().text = "Din pris: " + Global.offers[i]["Price"] as string + " kr.";
      scrollViewObj.transform.Find("Text (3)").gameObject.GetComponent<Text>().text = "Spar: " + Global.offers[i]["AndresPris"] as string + " kr.";
      }


      This is where I get the trouble. For some reason Global.offers[i]["Store"] as string == null, witch of course means that I can't instantiate the object. I get this error:



      NullReferenceException: Object reference not set to an instance of an object
      LoadOffers.Start () (at Assets/Scripts/LoadOffers.cs:36)



      It is so weird, because when I try to debug I get some conflicting results:



      The length of the array is 19. So it is not empty.



      When I try to Debug.Log the array out I get:



      System.Collections.Generic.Dictionary`2[System.String,System.Object]



      But when I search for values with keys like:



      Debug.Log(Global.offers[0]["Store"]);


      All I get is null. Am I searching wrong after the values? Or can anyone else see what I am doing wrong?







      c# firebase unity3d firebase-realtime-database






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 2 at 14:56









      Frank van Puffelen

      243k29387414




      243k29387414










      asked Jan 2 at 14:15









      Lasse BickmannLasse Bickmann

      286




      286
























          1 Answer
          1






          active

          oldest

          votes


















          1














          The Problem



          Your main problem is that Global.offers
          is an array and therefore has a fixed length and can not be enlarged dynamically that simple (you would have to copy the array everytime!)



          You kind of tried to solve this in Handle_ChildAdded but in the line



          Global.offers = new Dictionary<string, object>[Global.storesCount+1];


          what you actually do is creating a new empty(!) array of dictionaries with length Global.storeCount+1. You don't copy the current values to a new array.



          so after all executions what you get is an array with only null. Only the last item of the array will have the content coming from



          Global.offers[Global.storeCount] = dict;


          so only the last value will actually be set. It looks somewhat like



          {null, null, null, null, ..., Dictionary<string, object> }


          that's why the length is a correct value. Your exception is actually already thrown the moment you try to access



          Global.offers[0]


          which is null.





          Solution



          I would recommend not to use an array at all but instead a List which in contrary to the array can grow dynamically



          [System.Serializable]
          public class Global
          {
          public static List<Dictionary<string, object>> offers = new List<Dictionary<string, object>>();
          }


          and than before starting to fill the list by adding all dictionaries you should actually somwhere call



          Global.offers.Clear();


          to reset the list otherwise it keeps growing bigger and bigger with every loading of the database. Also if you are absolutely sure you call this only once you might not need this I would always recommend to do it in order to have a clean, in general working solution.



          And later add your elements in



          void Handle_ChildAdded(object sender, ChildChangedEventArgs e)
          {
          if (e.DatabaseError != null)
          {
          Debug.LogError(e.DatabaseError.Message);
          return;
          }
          // Do something with the data in args.Snapshot
          if (e.Snapshot.Value != null)
          {
          var dict = e.Snapshot.Value as Dictionary<string, object>;

          if (dict != null)
          {
          Debug.Log(dict);
          Global.offers.Add(dict);
          hasHaded = true;
          }
          }
          }




          Later you do access elements in a List the same way as in an array



          Debug.Log(Global.offers[0]["Store"]);




          Note that you also don't need the variable storeCount neither in your solution - you could have simply used



          Global.offers.Length


          nor in this new solution - you can simply use



          Global.offers.Count





          share|improve this answer


























          • Thank you so much! I will make it short: I love you! So many hours of watching on the same code, fixed with just an other declaration. You are a life saver!

            – Lasse Bickmann
            Jan 3 at 9:45











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54007911%2farray-of-dictionaries-with-unity-and-firebase-database-get-values-from-key%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          The Problem



          Your main problem is that Global.offers
          is an array and therefore has a fixed length and can not be enlarged dynamically that simple (you would have to copy the array everytime!)



          You kind of tried to solve this in Handle_ChildAdded but in the line



          Global.offers = new Dictionary<string, object>[Global.storesCount+1];


          what you actually do is creating a new empty(!) array of dictionaries with length Global.storeCount+1. You don't copy the current values to a new array.



          so after all executions what you get is an array with only null. Only the last item of the array will have the content coming from



          Global.offers[Global.storeCount] = dict;


          so only the last value will actually be set. It looks somewhat like



          {null, null, null, null, ..., Dictionary<string, object> }


          that's why the length is a correct value. Your exception is actually already thrown the moment you try to access



          Global.offers[0]


          which is null.





          Solution



          I would recommend not to use an array at all but instead a List which in contrary to the array can grow dynamically



          [System.Serializable]
          public class Global
          {
          public static List<Dictionary<string, object>> offers = new List<Dictionary<string, object>>();
          }


          and than before starting to fill the list by adding all dictionaries you should actually somwhere call



          Global.offers.Clear();


          to reset the list otherwise it keeps growing bigger and bigger with every loading of the database. Also if you are absolutely sure you call this only once you might not need this I would always recommend to do it in order to have a clean, in general working solution.



          And later add your elements in



          void Handle_ChildAdded(object sender, ChildChangedEventArgs e)
          {
          if (e.DatabaseError != null)
          {
          Debug.LogError(e.DatabaseError.Message);
          return;
          }
          // Do something with the data in args.Snapshot
          if (e.Snapshot.Value != null)
          {
          var dict = e.Snapshot.Value as Dictionary<string, object>;

          if (dict != null)
          {
          Debug.Log(dict);
          Global.offers.Add(dict);
          hasHaded = true;
          }
          }
          }




          Later you do access elements in a List the same way as in an array



          Debug.Log(Global.offers[0]["Store"]);




          Note that you also don't need the variable storeCount neither in your solution - you could have simply used



          Global.offers.Length


          nor in this new solution - you can simply use



          Global.offers.Count





          share|improve this answer


























          • Thank you so much! I will make it short: I love you! So many hours of watching on the same code, fixed with just an other declaration. You are a life saver!

            – Lasse Bickmann
            Jan 3 at 9:45
















          1














          The Problem



          Your main problem is that Global.offers
          is an array and therefore has a fixed length and can not be enlarged dynamically that simple (you would have to copy the array everytime!)



          You kind of tried to solve this in Handle_ChildAdded but in the line



          Global.offers = new Dictionary<string, object>[Global.storesCount+1];


          what you actually do is creating a new empty(!) array of dictionaries with length Global.storeCount+1. You don't copy the current values to a new array.



          so after all executions what you get is an array with only null. Only the last item of the array will have the content coming from



          Global.offers[Global.storeCount] = dict;


          so only the last value will actually be set. It looks somewhat like



          {null, null, null, null, ..., Dictionary<string, object> }


          that's why the length is a correct value. Your exception is actually already thrown the moment you try to access



          Global.offers[0]


          which is null.





          Solution



          I would recommend not to use an array at all but instead a List which in contrary to the array can grow dynamically



          [System.Serializable]
          public class Global
          {
          public static List<Dictionary<string, object>> offers = new List<Dictionary<string, object>>();
          }


          and than before starting to fill the list by adding all dictionaries you should actually somwhere call



          Global.offers.Clear();


          to reset the list otherwise it keeps growing bigger and bigger with every loading of the database. Also if you are absolutely sure you call this only once you might not need this I would always recommend to do it in order to have a clean, in general working solution.



          And later add your elements in



          void Handle_ChildAdded(object sender, ChildChangedEventArgs e)
          {
          if (e.DatabaseError != null)
          {
          Debug.LogError(e.DatabaseError.Message);
          return;
          }
          // Do something with the data in args.Snapshot
          if (e.Snapshot.Value != null)
          {
          var dict = e.Snapshot.Value as Dictionary<string, object>;

          if (dict != null)
          {
          Debug.Log(dict);
          Global.offers.Add(dict);
          hasHaded = true;
          }
          }
          }




          Later you do access elements in a List the same way as in an array



          Debug.Log(Global.offers[0]["Store"]);




          Note that you also don't need the variable storeCount neither in your solution - you could have simply used



          Global.offers.Length


          nor in this new solution - you can simply use



          Global.offers.Count





          share|improve this answer


























          • Thank you so much! I will make it short: I love you! So many hours of watching on the same code, fixed with just an other declaration. You are a life saver!

            – Lasse Bickmann
            Jan 3 at 9:45














          1












          1








          1







          The Problem



          Your main problem is that Global.offers
          is an array and therefore has a fixed length and can not be enlarged dynamically that simple (you would have to copy the array everytime!)



          You kind of tried to solve this in Handle_ChildAdded but in the line



          Global.offers = new Dictionary<string, object>[Global.storesCount+1];


          what you actually do is creating a new empty(!) array of dictionaries with length Global.storeCount+1. You don't copy the current values to a new array.



          so after all executions what you get is an array with only null. Only the last item of the array will have the content coming from



          Global.offers[Global.storeCount] = dict;


          so only the last value will actually be set. It looks somewhat like



          {null, null, null, null, ..., Dictionary<string, object> }


          that's why the length is a correct value. Your exception is actually already thrown the moment you try to access



          Global.offers[0]


          which is null.





          Solution



          I would recommend not to use an array at all but instead a List which in contrary to the array can grow dynamically



          [System.Serializable]
          public class Global
          {
          public static List<Dictionary<string, object>> offers = new List<Dictionary<string, object>>();
          }


          and than before starting to fill the list by adding all dictionaries you should actually somwhere call



          Global.offers.Clear();


          to reset the list otherwise it keeps growing bigger and bigger with every loading of the database. Also if you are absolutely sure you call this only once you might not need this I would always recommend to do it in order to have a clean, in general working solution.



          And later add your elements in



          void Handle_ChildAdded(object sender, ChildChangedEventArgs e)
          {
          if (e.DatabaseError != null)
          {
          Debug.LogError(e.DatabaseError.Message);
          return;
          }
          // Do something with the data in args.Snapshot
          if (e.Snapshot.Value != null)
          {
          var dict = e.Snapshot.Value as Dictionary<string, object>;

          if (dict != null)
          {
          Debug.Log(dict);
          Global.offers.Add(dict);
          hasHaded = true;
          }
          }
          }




          Later you do access elements in a List the same way as in an array



          Debug.Log(Global.offers[0]["Store"]);




          Note that you also don't need the variable storeCount neither in your solution - you could have simply used



          Global.offers.Length


          nor in this new solution - you can simply use



          Global.offers.Count





          share|improve this answer















          The Problem



          Your main problem is that Global.offers
          is an array and therefore has a fixed length and can not be enlarged dynamically that simple (you would have to copy the array everytime!)



          You kind of tried to solve this in Handle_ChildAdded but in the line



          Global.offers = new Dictionary<string, object>[Global.storesCount+1];


          what you actually do is creating a new empty(!) array of dictionaries with length Global.storeCount+1. You don't copy the current values to a new array.



          so after all executions what you get is an array with only null. Only the last item of the array will have the content coming from



          Global.offers[Global.storeCount] = dict;


          so only the last value will actually be set. It looks somewhat like



          {null, null, null, null, ..., Dictionary<string, object> }


          that's why the length is a correct value. Your exception is actually already thrown the moment you try to access



          Global.offers[0]


          which is null.





          Solution



          I would recommend not to use an array at all but instead a List which in contrary to the array can grow dynamically



          [System.Serializable]
          public class Global
          {
          public static List<Dictionary<string, object>> offers = new List<Dictionary<string, object>>();
          }


          and than before starting to fill the list by adding all dictionaries you should actually somwhere call



          Global.offers.Clear();


          to reset the list otherwise it keeps growing bigger and bigger with every loading of the database. Also if you are absolutely sure you call this only once you might not need this I would always recommend to do it in order to have a clean, in general working solution.



          And later add your elements in



          void Handle_ChildAdded(object sender, ChildChangedEventArgs e)
          {
          if (e.DatabaseError != null)
          {
          Debug.LogError(e.DatabaseError.Message);
          return;
          }
          // Do something with the data in args.Snapshot
          if (e.Snapshot.Value != null)
          {
          var dict = e.Snapshot.Value as Dictionary<string, object>;

          if (dict != null)
          {
          Debug.Log(dict);
          Global.offers.Add(dict);
          hasHaded = true;
          }
          }
          }




          Later you do access elements in a List the same way as in an array



          Debug.Log(Global.offers[0]["Store"]);




          Note that you also don't need the variable storeCount neither in your solution - you could have simply used



          Global.offers.Length


          nor in this new solution - you can simply use



          Global.offers.Count






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jan 3 at 9:54

























          answered Jan 3 at 6:49









          derHugoderHugo

          8,78731535




          8,78731535













          • Thank you so much! I will make it short: I love you! So many hours of watching on the same code, fixed with just an other declaration. You are a life saver!

            – Lasse Bickmann
            Jan 3 at 9:45



















          • Thank you so much! I will make it short: I love you! So many hours of watching on the same code, fixed with just an other declaration. You are a life saver!

            – Lasse Bickmann
            Jan 3 at 9:45

















          Thank you so much! I will make it short: I love you! So many hours of watching on the same code, fixed with just an other declaration. You are a life saver!

          – Lasse Bickmann
          Jan 3 at 9:45





          Thank you so much! I will make it short: I love you! So many hours of watching on the same code, fixed with just an other declaration. You are a life saver!

          – Lasse Bickmann
          Jan 3 at 9:45




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54007911%2farray-of-dictionaries-with-unity-and-firebase-database-get-values-from-key%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          MongoDB - Not Authorized To Execute Command

          in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith

          How to fix TextFormField cause rebuild widget in Flutter