title: How to parse Object of Map<String, Object> returned from documentSnapshot.getData() of Google Cloud Firestore into a POJO?
body: <p>documentSnapshot.getData() method of Cloud Firestore returns a Map&lt; String, Object >. My db structure looks like below:</p>
  
  <p><a href="https://i.stack.imgur.com/osUQs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/osUQs.png" alt="Database Structure/Schema"></a></p>
  
  <p>Now I have a POJO as below:</p>
  
  <pre><code>public class Plan {
  
      private ArrayList&lt;String&gt; items;
      private String name;
      private int price;
      private int years;
  
      public Plan() {
      }
  
      public Plan(ArrayList&lt;String&gt; items, String name, int price, int years) {
          this.items = items;
          this.name = name;
          this.price = price;
          this.years = years;
      }
  
      public List&lt;String&gt; getItems() {
          return items;
      }
  
      public void setItems(ArrayList&lt;String&gt; items) {
          this.items = items;
      }
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      public int getPrice() {
          return price;
      }
  
      public void setPrice(int price) {
          this.price = price;
      }
  
      public int getYears() {
          return years;
      }
  
      public void setYears(int years) {
          this.years = years;
      }
  }
  </code></pre>
  
  <p>As you see, all I want is a list of Object from the Map&lt; String, Object > returned from documentSnapshot.getData() method. The String, i.e., the key part, has to be ignored. I don't want to use keys to extract from Map as I want the algorithm to dynamically create a list of all plans (POJO) irrespective of the number of key-value pairs in the map.</p>
  
  <p>Below is the code I'm using:</p>
  
  <pre><code>documentReference.get().addOnSuccessListener(new OnSuccessListener&lt;DocumentSnapshot&gt;() {
              @Override
              public void onSuccess(DocumentSnapshot documentSnapshot) {
                  if (documentSnapshot.exists()) {
                      Map&lt;String, Object&gt; planMap = documentSnapshot.getData();
                      // how to parse the Object inside Map&lt;String, Object&gt; above to POJO Plan.class here
                      }
                  }
              }
          });
  </code></pre>
  
  <p>I tried many ways but I am unable to parse that Object into my POJO. Please help. Thanks in advance.</p>