0

I tried searching this on the Firebase Google Groups/Slack/SO but couldn't find anything concrete except this answer from 2016.

I trying to implement a custom JSON deserializer to convert the DataSnapshot to an object. The Firebase implement works as expected however I have a few edge cases where the Firestore database may be storing null values for fields, or simply not exist. My goal is to provide default values so that I don't have to handle null pointers in each instance. Something similar to this. Is that possible?

Dan McGrath
  • 41,220
  • 11
  • 99
  • 130
najm
  • 834
  • 1
  • 13
  • 32
  • You can just write code to set default values if you see that they're null. This won't happen automatically. – Doug Stevenson Apr 08 '18 at 08:49
  • Right, but at some point, that becomes really repetitive or just too much boilerplate if I have a lot of fields to work with. Using a custom deserializer -- like the one I linked -- would allow me to code once and forget about edge cases. – najm Apr 08 '18 at 17:33

0 Answers0