Kotlinx.serialization: Computed property not serialize

Created on 16 Apr 2020  路  2Comments  路  Source: Kotlin/kotlinx.serialization

A data class with computed property:

data class Bean(val name: String) {
  val computed: String
    get() = "--$name"  
}

Use `kotlinx-serialization-runtime-0.20.0':

val result = Json(Stable).stringify(Bean.serializer(), Bean(name = "rj"))

the result is {"name":"rj"} but I want it to be {"name":"rj","computed":"--rj"}. How?

design feature

Most helpful comment

I need this feature also.

Example use case: my image urls are computed and not stored in the database.

All 2 comments

It is not supported yet because it is quite a rare use case

I need this feature also.

Example use case: my image urls are computed and not stored in the database.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kdabir picture kdabir  路  3Comments

ersin-ertan picture ersin-ertan  路  3Comments

lonevetad picture lonevetad  路  3Comments

kastork picture kastork  路  3Comments

slomkowski picture slomkowski  路  4Comments