Skip to content

(yaml) Empty string serialized without quotes if MINIMIZE_QUOTES is enabledΒ #50

@tim-palmer

Description

@tim-palmer

YAMLGenerator does not quote empty strings if MINIMIZE_QUOTES is enabled.

The YAML 1.2 spec says that plain (unquoted) scalars cannot be empty i.e. an empty string must always be quoted.

      YAMLFactory f = new YAMLFactory();
      f.configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true);

      YAMLMapper mapper = new YAMLMapper(f);

      Map<String, Object> content = new HashMap<>();
      content.put("key", "");
      String yaml = mapper.writeValueAsString(content).trim();

      assertEquals("---\nkey: \"\"", yaml); // fails - actual output is "---\nkey:"

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