Hey all, so I'm storing a `@Serializable` class on...
# serialization
b
Hey all, so I'm storing a
@Serializable
class on disk that persists between user sessions. Does anyone here have experience with making sure that new versions of this class are compatible with the old serialized strings? In the case of field name changes, must I keep both versions of the class and manually do the transformations myself whenever a new version of the app is pushed? Any thoughts or ideas are welcome.
n
make sure to have default values for new fields.. you can add aliases to fields too if you need to fix it manually you can decode it as a JsonObject, fix it up manully and then parse the fixed JsonObject, write that to disk afterwards you can configure
Json
to ignore unknown fields, for things that are not used at all anymore (and that do nto need to be transformed into other fields)
if you want full control.. i would suggest to have a
version
field, parse your file as a
JsonObject
and then run migration functions on it until it is on the latest version, then you can parse and roundtrip it back to disk
b
Cool. That makes a lot of sense. Thanks for these ideas!