firestore android adding "stability" field in custom Parcelable class while saving

632 Views Asked by At

I have a parcelable class Image

@Parcelize
data class Image(val id:String="",val url:String=""):Parcelable

and for saving in firestore

val data = HashMap<String,Any>()
data["title"] = "My Title"
data["image] = Image("dgdg1","https://someimagepath")
firestore.collection("collectionname").document(documentId).set(data,SetOptions.merge()).await()

data is getting saved in firestore but inside the "image" it is adding an extra field "stability" . The out put result is like this

{  
  "title":"My Title",  
  "image":{
    "stability":0,
    "id":"dgdg1",
    "url":"https://someimagepath"
  } 
}

why is this "stability" is automatically added to the image object.

1

There are 1 best solutions below

0
Robert G On

As per @BalaramNayak's comment:

Serializing Firebase uses the CustomClassMapper class. The serialize function takes all class-level fields, getters, and its Parent class getters and fields. In this case, Parcelable is the parent class with a getter method named getStability(). So while serializing it includes the stability field.

You may refer to the documentations below for additional information: