Reputation: 1192
I'm using autovalue for my entities and annotated them to allow json parsing.
There are new annotations in the new sdk: Exclude
, IgnoreExtraProperties
, ThrowOnExtraProperties
and @PropertyName
: https://firebase.google.com/docs/reference/android/com/google/firebase/database/PropertyName. But PropertyName seems to be missing from the sdk..
Upvotes: 6
Views: 5730
Reputation: 599601
We missed the @PropertyName
annotation in this release of the Firebase SDK for Android, but it was included in a release shortly after.
See this answer for a way to use Jackson explicitly with any version of the Firebase SDK: How to deserialise a subclass in Firebase using getValue(Subclass.class)
Upvotes: 6
Reputation: 41
BEFORE
@JsonIgnoreExtraProperties(ignoreUnknown=true)
public class ChatMessage {
public String name;
public String message;
@JsonIgnore
public String ignoreThisField;
}
dataSnapshot.getValue(ChatMessage.class)
AFTER
public class ChatMessage {
public String name;
public String message;
@Exclude
public String ignoreThisField;
}
dataSnapshot.getValue(ChatMessage.class)
Refer to https://firebase.google.com/support/guides/firebase-android#update_your_java_model_objects_numbered
Upvotes: 4