Skip to content

Make AbstractPolymorphicSerializer.findPolymorphicSerializerOrNull take a SerializersModule directly #3157

@Laxystem

Description

@Laxystem

What is your use-case and why do you need this feature?

I'm making a workaround for the Properties serializer to support deserializing multiple objects from the same properties file by using prefixes. For that, I need to make sure primitives can be deserialized from e.g. <prefix>=example (i.e. {"": "example"}) into "example". So I've made a wrapper decoder that passes the handling of structures to the original decoder (which is given a well-prefixed map), and I handle 'rogue' primitives by myself (as Properties.decodeFromMap<String>(mapOf("" to "something")) and Properties.encodeToMap("something") kills it).

I now want to have primitive polymorphic serializers have their value on the prefix itself, instead of <prefix>.value, so I need to copy Properties' mechanism for this. Problem is, despite only needing a SerializersModule, the function takes a CompositeDecoder and does not use it at all besides getting said serializers module, while my wrapper is not composite.

I'd use serializersModule.getPolymorphic, but that loses sealed classes functionality for whatever reason.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions