hawaiijnr.blogg.se

Data class kotlin serializable
Data class kotlin serializable






So Jackson deserializer seems to handle this correctly, whereas Fauna Java driver deserialization does not. If we compare to the Jackson deserialize/serialize library that is used to deserialize the request body from the frontend to my backend service, this is not a problem. Could this be it? In Kotlin, when a field is non-nullable, the field needs to be set upon object creation (providing the value to the constructor normally). GSON, Jackson, Kotlin serialization, Moshi, XML) provide the mechanism to automatically marshall data objects to/from JSON. The problem seems to lie in that the deserialization process first instantiates the data class with no values (because this is OK in Java) and then sets the values on every field afterwards. I think the default way should be, that a default serializer parses to and from ISO-8601. It is a string value and it is correctly returned from Fauna and received in my application. Define class, including all fields you want to be serialized, mark it as Serializable Make your data class to be its subtype: Serialize instances of. The value of the field in Fauna is not null.

data class kotlin serializable

One of my Kotlin data classes has a field that does not allow null values - a feature of Kotlin language (see here: Null safety | Kotlin) - and thus causes an exception to be thrown when data from Fauna is fetched and deserialization process and creation of instance of Kotlin data class is attempted. I’m writing a backend service in Kotlin and Spring Boot, and for Fauna integration I’m using the Java driver ( GitHub - fauna/faunadb-jvm: Scala and Java driver for FaunaDB).








Data class kotlin serializable