Thread
#serialization
    Nikky

    Nikky

    2 years ago
    is there anything like a alias for SerialModule ? or any other way to move / refactor sealed classes and have it parse old json that has values for
    type
    ?
    Dominaezzz

    Dominaezzz

    2 years ago
    Were you using the default
    @SerialName
    s before? You might have to explicitly use
    @SerialName
    with the old
    type
    s.
    Nikky

    Nikky

    2 years ago
    i can change it back so that the old code compiles.. but how would i migrate so that it recognizes
    "type": "oldpackage.Type"
    as a alias to
    newpackage.Type
    ? or is manual intervention required ?
    Dominaezzz

    Dominaezzz

    2 years ago
    You'll need to annotate all the subclasses with,
    @SerialName("oldpackage.Type")
    .
    Nikky

    Nikky

    2 years ago
    which means that that key will end up in the json 😕
    Dominaezzz

    Dominaezzz

    2 years ago
    Oh, you want both to work!
    Nikky

    Nikky

    2 years ago
    i want both to parse but the new one to be what
    stringify
    outputs, if possible..
    Dominaezzz

    Dominaezzz

    2 years ago
    I think this is more/less what you're looking for https://github.com/Kotlin/kotlinx.serialization/pull/772 .
    You can then register a "default" for the old names.
    Nikky

    Nikky

    2 years ago
    this looks like it could be useful..
    Dominaezzz

    Dominaezzz

    2 years ago
    It hasn't been released yet though, so will have to make due with a custom serializer. Like
    JsonTransformingSerializer
    .
    You can use that to edit the types if they're old.
    Nikky

    Nikky

    2 years ago
    so i cannot use the
    default {}
    block quite yet since this is not in a release.. 😢 well i hope it will be available soon