Failed to decode RealmList from primitive array
See original GitHub issueI’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?
Issue Analytics
- State:
- Created a year ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Gson deserialization for Realm list of primitives - Stack Overflow
I am using realm with gson. I have a modal which has a list of int type field. Realm does not support currently...
Read more >Convert an Array of Primitives to a List | Baeldung
In this short tutorial, we'll show how to convert an array of primitives to a List of objects of the corresponding type.
Read more >Realm: Create reactive mobile apps in a fraction of the time
If you add it to other field types, compilation will fail. Fields with primitive types and the RealmList type are required implicitly.
Read more >Groovy Language Documentation
Any indentation would yield a compilation error. ... 4, Assert that we created an array of primitive ints ...
Read more >Arrays - Learning the Java Language
class ArrayDemo { public static void main(String[] args) { // declares an array ... the compiler prints an error like the following, and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yeah, thanks! Just wanted to check if I’m not missing some built-in solution
Closing due to lack of feedback. @grigorevp If you still need assistance with this please let us know.