Todo app with multiple checkboxes using Type Converter with Gson in jetpack compose

แชร์
ฝัง
  • เผยแพร่เมื่อ 30 ต.ค. 2024

ความคิดเห็น • 4

  • @MohsenMashkour
    @MohsenMashkour  หลายเดือนก่อน +1

    If you have any requests about the tutorials you want to see, just leave a comment below! Subscribe to the channel if you don't want to miss the other parts. Thanks for watching.

  • @Lapakias
    @Lapakias หลายเดือนก่อน

    Hello and thank you for your classes from Greece. Can you please show how we can upload and monitor an app in play store?

  • @ubersticks
    @ubersticks หลายเดือนก่อน

    Can you comment on why GSON is useful for this? The basic Kotlin functions are simple too. Another option might be Kotlin serialization. What is the power of Gson?
    // converters using normai Kotlin
    @TypeConverter
    fun fromBooleanList(list: List): String {
    return list.joinToString(",") { it.toString() }
    }
    @TypeConverter
    fun toBooleanList(value: String): List {
    return value.split(",").map { it.toBoolean() }
    }

    • @MohsenMashkour
      @MohsenMashkour  17 วันที่ผ่านมา

      Great question! You’re right-Kotlin’s basic functions can handle simple conversions like the one you’ve shared. However, Gson becomes useful when you’re dealing with more complex data structures, such as nested objects or lists of custom objects. It can easily convert these types to and from JSON without you having to manually handle each field.
      For example, if your data model evolves and you start working with lists of more complex objects (not just booleans), Gson will handle serialization and deserialization automatically with minimal changes to your code. It also has great support for complex features like custom type adapters, making it more flexible in the long run.
      As for Kotlin Serialization, it’s indeed a solid alternative and has the benefit of being Kotlin-first with better performance in some cases. But Gson has been around longer, is widely supported, and works out of the box with many existing libraries, which might make it more convenient depending on your project.
      If your app stays simple, your Kotlin converter works perfectly fine. But Gson is often chosen for scalability and flexibility.