Skip to content

Deserialization: empty String field to null value doesn't work #668

@danibs

Description

@danibs

Hi.
I'm using <jackson-bom.version>2.17.2</jackson-bom.version> and already resolved my problem with Date using this configuration #561 (comment) .

Now what I want is to convert:

<x><TESTO></TESTO></x>

to the field:

	@JsonProperty( "TESTO" )
	private String testo;

and when the text is empty what I want is to have null in testo field.
What I already tried is all the combinations of:

XmlMapper mapper = new XmlMapper();

mapper.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);
mapper.coercionConfigFor( LogicalType.Textual ).setCoercion( CoercionInputShape.EmptyString, CoercionAction.AsNull );

I also tried adding:

mapper.coercionConfigDefaults().setCoercion(  CoercionInputShape.EmptyString, CoercionAction.AsNull);

Then I tried to debug but it seams that coercion is not used.

Any idea?

Thanks alot

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions