title: Kotlin Android Firebase Database Hashmap Cast to Class
body: <p>I am trying to get data from a firebase database.
  The breakpoints show it is getting the data, but it looks like I am not properly assigning it to my class.</p>
  
  <p>which causes this exception :</p>
  
  <blockquote>
    <p>java.lang.ClassCastException: java.util.HashMap cannot be cast to
    Class</p>
  </blockquote>
  
  <pre><code>override fun onDataChange(p0: DataSnapshot?) {
      if (p0!!.exists()){
          val children = p0!!.children
          children.forEach {
              println(it.value.toString())
              var item : DashboardItem = it.value as DashboardItem
              println(item)
          }
      }
  }
  </code></pre>
  
  <p>this is the DB export :</p>
  
  <pre><code>{
   "dashboard" : [ 
      { "name" : "News"}, 
      { "name" : "Chatroom"},
      { "name" : "Music"},
      { "name" : "Quotes"},
      { "name" : "Reminder"},
      { "name" : "Poll"},
      { "name" : "Suggestion"},
      { "name" : "LogOut"} ]  
  }
  </code></pre>
  
  <p>the class object i want to create </p>
  
  <pre><code>data class DashboardItem(val name: String = "")
  </code></pre>