Skip to content

Empty String deserialized as null instead of empty string #130

@iulianrosca

Description

@iulianrosca

Hello,

I have the following issue/question for which I was hoping to find a easy solution.

I have inherited a large codebase where I am trying to migrate from jackson 2.6.4 to 2.9.8. The project contains multiple YAML files which are deserialized using com.fasterxml.jackson.dataformat.yaml.YAMLMapper. Most of these files contain empty fields e.g.

emptyStringField:

With version 2.6.4 these fields were being decoded to empty strings, while after migrating to 2.9.8 the field evaluated to null. I have managed to trace the diverging behavior in com.fasterxml.jackson.dataformat.yaml.YAMLParser#_decodeScalar.
The 2.6 version was evaluating the field to JsonToken.VALUE_STRING while the 2.9 version is using SnakeYaml implicit resolvers and evaluates to JsonToken.VALUE_NULL.

What is the desirable way to keep the behavior from 2.6, deserialize empty fields to empty string instead of null, after migrating to 2.9?

Metadata

Metadata

Assignees

No one assigned

    Labels

    yamlIssue related to YAML format backend

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions