Skip to content

When field names are reserved words, they should be written out with quotes #68

@baconmania

Description

@baconmania

https://github.com/FasterXML/jackson-dataformat-yaml/blob/master/src/main/java/com/fasterxml/jackson/dataformat/yaml/YAMLGenerator.java specifies that YAML keys will always be written with STYLE_NAME, e.g. without quotes.

    // for field names, leave out quotes
    private final static Character STYLE_NAME = null;
...
    private final void _writeFieldName(String name)
        throws IOException
    {
        _writeScalar(name, "string", STYLE_NAME);
    }

But this breaks parsers when you write a map with a key that is a reserved word in YAML, e.g. no. If _writeFieldName() encounters a field that is one of { y, true, yes, on, n, false, no, off }, it should use STYLE_QUOTED.

Actual definition of such boolean values can be found here:

https://yaml.org/type/bool.html

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