Home > Back-end >  Firebase and Android, getHttpsCallable how to deserialize json into object
Firebase and Android, getHttpsCallable how to deserialize json into object

Time:12-23

I use firestore for all of my networking in my android app. It works well and out of the box it deserializes into objects for me. Now I need to use an httpsCallable, and I rather not import a new third party library or kotlinx.serizlization in order to deserialize this single call. Is there a way to hook into the deserializing that firestore already seems to have built in?

CodePudding user response:

I don't think anything is built into Firebase for this yet, although it could actually make a reasonable feature request to file on the Github repo of the Firebase Android SDK.

In the meantime the best you is look at the source for the DocumentSnapshot.toObject method, which delegates most of its work to CustomClassMapper.convertToCustomClass(data, valueType, getReference()).

This CustomClassMapper class is also included in the repo, and is public (though not included in the public documentation for the SDK), so you might be able to use the class in your own project too.

  • Related