I have my kotlin class as
class Center : Serializable {
var active: Boolean? = null
var address: String? = null
var isJobAccessGranted: Boolean? = null
}
here is how i am getting value
//from java class
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
centerMap.put(dataSnapshot.getKey(), dataSnapshot.getValue(Center.class));
}
but problem is that i am getting value of active field without any issue. But isJobAccessGranted boolean field always remains null. I have tested with some other boolean removing is prefix which works fine. I don't get Boolean value when i use isActive or isJobAccessGranted. Can anyone explain me why i am facing this issue. #AskFirebase
As mentioned in comment in Kotlin you should add @field:JvmField for every Boolean field in class, as when Kotlin translates to Java it generates setters, which names couldnt be resolved by JSON parser. And @field:JvmField annotation overrides this feature and there will be correct setters names and JSON will be parsed correctly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With