Skip to content

null type id handling does not work with writeTypePrefix() #4407

@cowtowncoder

Description

@cowtowncoder

(note: regression partly due to #3373, reported f.ex as #4354 (but not just that))

So: if custom TypeIdResolver returns null from idFromValue() or idFromValueAndType(), result is that underlying JsonGenerator.writeTypePrefix() call is omitted. This may work for some cases, but won't for others, because necessary parts of structure are missing.

Conceptually the idea would be that null for Type Id means "do not add Type Id", but doing so cannot be done by simply skipping calls to JsonGenerators writeTypePrefix() and writeTypeSuffix(): rather, calls need to be made but these methods need to be aware of possibly missing type id and output whatever else is necessary.

EDIT: another way to describe this is that if idFromValue() / idFromValueAndType() returns null, serialization occurs AS IF non-polymorphic serialization was used. For As.PROPERTY / As.EXISTING_PROPERTY, for example, output would be similar but without "type": "typeId" entry in JSON Object; and for wrappers (As.ARRAY_WRAPPER / As.OBJECT_WRAPPER) no wrapping is added.

Metadata

Metadata

Assignees

No one assigned

    Labels

    2.18Issues planned at 2.18 or later

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions