Skip to content

Add YAMLParser.Feature.PARSE_BOOLEAN_LIKE_WORDS_AS_STRINGS to allow parsing "boolean" words as strings instead of booleans #388

@axelniklasson

Description

@axelniklasson

Right now YAMLParser._matchYAMLBoolean provides no flexibility to avoid words that are considered booleans to be parsed as strings instead, which is actually sometimes the desired behaviour and a good candidate for a feature flag in my opinion. I therefore propose the following

  • Introduce a new YAMLParser.Feature called PARSE_TRUTHY_WORDS_AS_STRINGS (open for suggestion on names)
  • When enabling this flag, the following words (converted to lowercase) will be parsed as strings instead of booleans:
    • yes
    • no
    • on
    • off
    • y
    • n

Note that false and true will still be parsed as booleans.

Let me know what you think! I'll be happy to help out with a PR here.

Related issue: #129

Metadata

Metadata

Assignees

No one assigned

    Labels

    2.15Fix or feature targeted at 2.15 releaseyamlIssue related to YAML format backend

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions