Hi there! Maybe my question is really very simple,...
# serialization
o
Hi there! Maybe my question is really very simple, but so far I cannot find the documentation for this... 😞 Suppose I have a serializable data class
Copy code
@Serializable
data class Foo(
    val bar: String
)
which has many json files created and stored on disk. The all look like this:
Copy code
{
  "bar": "value"
}
Now I need to rename the field, also affecting the newly serialized output. BUT: I still need to be able to read (deserizlize) the old files without touching them. So:
Copy code
@Serializable
data class Foo(
    val baz: String
)
is the new format.. where baz actually is just the new name for bar... I tried
@SerialName(...)
but that does not work, it does not act as an alias, it just changes the serial name for both read & write... Any hints how this is supposed to be done? Thanks!
e
@JsonNames would probably do the trick?
💯 2