I need to deserialize the results of a search quer...
# serialization
r
I need to deserialize the results of a search query to Algolia. The result object contains a
hits
array containing the results of the query. Depending on the index the query was run on, the model of these results change. How do I implement that with
kotlinx.serialization
? - Can I use generics? - Can I use inheritance, with one subclass per model? - Can I say that these results should stay “raw”, like JsonObject or String, and deserialize them later to the correct model?
q
Hello Gael ! I am an Android engineer working at Algolia, I have a few questions to better understand your specific use case. - Are you using the Android API client ? - Do you know all possible forms of your models in advance ? - Which version of the kotlinx.serialization library are you using ?
r
Hi Quentin! - No we’re not, we feel like the client lacks both documentation and functionality, and we have a lot of advantages to making our own - The models are directly imported from other multiplatform libraries implementing microservices who return the same models - 0.10.0 Basically our own client won’t be generic, it will contain only the entry point we need and return our models directly. Our client basically wrap and hides Algolia so that we don’t have to reimplement everything in all our mobile apps (and maybe non-mobile too in the future)
q
Let's move this conversation to DM 🙂