appwrite / sdk-generator

Generating SDKs for multiple programming languages and platforms βš™οΈ

Home Page:https://appwrite.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

πŸ› Bug Report: [Android SDK] Serialization Engine

SebastianTMo opened this issue Β· comments

πŸ‘Ÿ Reproduction steps

When using a serialization engine other than Gson in your app (for example KotlinXSerialization) the annotations to your data classes are not recognised by the Gson serialization engine used by the SDK.

πŸ‘ Expected behavior

Propper object parsing.

I think the best solution for this problem might be choosing the serialization engine beforehand but happy to hear your oppinions on this one.

πŸ‘Ž Actual Behavior

The problem occures when casting RealtimeResponseEvents.payload within the subscribe-functions (using the payloadType parameter). The SDK will try to cast the payload-object using Gson and will fail for $id and $permission (as you need to annotate them propperly to be parsed due to the $-sign). This will also occur, when your data class parameter names will differ from the parameter names in the json-String.

Current Workaround:
Double-Annotation of the problematic parameters.

🎲 Appwrite version

Version 0.11.x

πŸ’» Operating system

Linux

🧱 Your Environment

No response

πŸ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏒 Have you read the Code of Conduct?

@abnegate please take a look at this

Cases where serialization failed ($id and $permission etc.) is fixed in version 0.3.3 πŸ™‚

It is a little harder to solve for cases where data class parameter names do not match JSON names - switching to a different library would result in the same problem for developers using any other library, and including multiple would bloat the SDK. I will close this as the bug is fixed but will investigate how to provide better support for other serializers.