title: FirebaseDatabaseException: Expected a List while deserializing, but got a class java.util.HashMap
body: <p>How should I read this data from firebase? 
  Because this is a serious issue, Let me explain the issue briefly. 
  So, like in the below json image I have a single data <strong>max_slide</strong> which I need to retrieve but I can't because of the below <strong>Exception</strong>.</p>
  
  <blockquote>
    <p>com.google.firebase.database.DatabaseException: Expected a List while deserializing, but got a class java.util.HashMap</p>
  </blockquote>
  
  <p>And this exception is showing because there is no list in the JSON for now. But when I add some data there to make a list is in JSON. There was no such exception. 
  <a href="https://i.stack.imgur.com/3yf22.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3yf22.png" alt="Firebase JSON Format"></a></p>
  
  <p><strong>Exceptions Occur Only When A Single Data exist!</strong> </p>
  
  <p>Below code, I'm using to retrieve data. Where is the fault?</p>
  
  <pre><code>        lessonProgressList = new ArrayList&lt;&gt;();
          mDatabaseReference = firebaseDatabase.getReference("/lesson");
          mDatabaseReference.addListenerForSingleValueEvent(new ValueEventListener() {
              @Override
              public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
                  if (dataSnapshot.exists() &amp;&amp; dataSnapshot.getValue() != null) {
  
                      for (DataSnapshot ds: dataSnapshot.getChildren()) {
                          Log.d(TAG, "DataSnapshot Loop");
                          Lesson lesson = ds.getValue(Lesson.class);     // THIS LINE THROWING THE EXCEPTION
                          lessonProgressList.add(lesson);
                      }
  
                      listener.updateLessonsProgress(lessonProgressList);
                      Log.d(TAG, "DataSnapshot Success");
  
                  } else {
                      Log.d(TAG, "Failed!");
                  }
              }
              @Override
              public void onCancelled(@NonNull DatabaseError databaseError) { }
          });
  </code></pre>
  
  <p>Lesson.java  class</p>
  
  <pre><code>public class Lesson implements Serializable{
  
      private List&lt;Topic&gt; topic;
  
      public Lesson() {
      }
  
      public Lesson(List&lt;Topic&gt; topic) {
          this.topic = topic;
      }
  
      public List&lt;Topic&gt; getTopic() {
          return topic;
      }
  }
  </code></pre>
  
  <p>Topic.java</p>
  
  <pre><code>public class Topic implements Serializable {
      private int max_slide;
  
      public Topic(int max_slide) { this.max_slide = max_slide; }
  
      public Topic() { }
  
      public int getMax_slide() {
          return max_slide;
      }
  }
  </code></pre>