title: Deserialize a Firebase Data-Snapshot to a Kotlin data class
body: <p>Hi I have a Kotlin data class as follows</p>
  
  <pre><code>data class User (
          @get:Exclude val gUser: Boolean,
          @get:Exclude val uid: String,
          @get:PropertyName("display_name") val displayName: String,
          @get:PropertyName("email") val email: String,
          @get:PropertyName("account_picture_url") val accountPicUrl: String,
          @get:PropertyName("provider") val provider: String
  )
  </code></pre>
  
  <p>I am able to serialize the object without an issues. But i'm having trouble deserializing the object when doing a firebase query. Currently this is what i'm doing to get the data</p>
  
  <pre><code>_firebaseReference.child(getString(R.string.firebase_users_key)).child(user.uid)
          .setValue(user).addOnCompleteListener{
      _firebaseReference.child("users").child(user.uid)
              .addListenerForSingleValueEvent(object : ValueEventListener {
          override fun onCancelled(p0: DatabaseError) {
  
          }
  
          override fun onDataChange(p0: DataSnapshot) {
              if (p0.exists()) {
                  val userHash = p0.value as HashMap&lt;*, *&gt;
                  var currentUser: User
                  if (userHash[getString(R.string.provider_key)]
                          != getString(R.string.provider_google)) {
                      currentUser = User(false, p0.key!!, 
                              userHash["display_name"].toString(), 
                              userHash["email"].toString(),
                              userHash["account_picture_url"].toString(), 
                              userHash["provider"].toString())
                  } else {
                      currentUser = User(true, p0.key!!, 
                              userHash["display_name"].toString(), 
                              userHash["email"].toString(), 
                              userHash["account_picture_url"].toString(), 
                              userHash["provider"].toString())
                  }
              }
          }
  
      })
  }
  </code></pre>
  
  <p>This is only a test project that i'm working on to practice my Kotlin, but this is something I would like to figure out.</p>
  
  <p>If i'm doing it completely wrong please let me know, any advise would be greatly appreciated</p>
  
  <p>Thanks</p>