0

In our Firebase database json tree, we have a property name "creation-date". We are now upgrading to Firebase 9 and have a problem, since this name contains a hyphen and therefore is not a valid java identifier.

In prior versions of Firebase, we could use the Jackson annotation:

@JsonGetter("creation-date") // This does not exist in Firebase9
public long getCreationDate() {
    return creationDate;
}
public void setCreationDate(long creationDate) {
    this.creationDate = creationDate;
}

However, this does not work in Firebase 9 since it no longer uses Jackson and instead uses it's own custom serializer. I did find replacements for other annotations, (i.e., @JsonIgnore -> @Exclude) however I don't see any annotation equivalent of @JsonGetter.

How can I control the serialized name of a property in Firebase 9?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Greg Ennis
  • 14,917
  • 2
  • 69
  • 74
  • That property is not available in the new SDK yet. See [this question](http://stackoverflow.com/questions/37330156/new-firebase-json-annotations). If you need to control the property names, you can explicitly use Jackson for the moment (which we used internally in the 2.x SDKs). See [this answer](http://stackoverflow.com/questions/37547399/how-to-deserialise-a-subclass-in-firebase-using-getvaluesubclass-class/37548330#37548330) – Frank van Puffelen Jun 24 '16 at 18:05
  • @FrankvanPuffelen thanks for the reply. I noticed you replied in the other thread on May 19 that this would be out in the "next release". Any idea when that will be? It looks like using Jackson myself requires a lot of code manually converting my classes back and forth, so I'm not sure if it wouldn't just be easier to change the names of all the properties. – Greg Ennis Jun 24 '16 at 20:02

0 Answers0