Uploaded image for project: 'Realm Kotlin'
  1. Realm Kotlin
  2. RKOTLIN-576

Failed to decode RealmList from primitive array

      I'd like to store an array of primitives in my Realm object, so I am declaring it like:

      @Serializable
      class Some: RealmObject {
      
          @PrimaryKey
          var id: String = uuid4().toString()
      
          private var list: RealmList<Int> = realmListOf()
      
      }
      

      When trying to decode it from the server response I get Expected class kotlinx.serialization.json.JsonObject as the serialized body of kotlinx.serialization.Polymorphic<RealmList>, but had class kotlinx.serialization.json.JsonArray, which is gone in case I mark this list property as @Transient.

      I am using Ktor with Json serializer:

      val httpClient = HttpClient {
          expectSuccess = true
          install(ContentNegotiation) {
              json(Json {
                  ignoreUnknownKeys = true
                  encodeDefaults = true
                  prettyPrint = true
              })
          }
          install(HttpTimeout) {
              requestTimeoutMillis = 15000
          }
      }
      

      Am I missing something? Or RealmList needs a custom serializer to be specified for the class which is using it?

            Assignee:
            nabil.hachicha@mongodb.com Nabil Hachicha
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: