Skip to content

Jackson YAML parser fails to load JSON files that use tabs for indentation #40

@andylowry

Description

@andylowry

The following shoudl be perfectly valid YAML, but the Jackson YAML parser fails to parse it:

{
	x: 1 # indentation is a tab character
}

YAML doesn't permit tabs in indentation in block content, but the initial open brace starts flow-style content, where initail indentation - including tabs - is supposed to be discarded.

To work around this, we now preprpocess file content to replace any string of tabs at the beginning of any line with an equal-length string of spaces. This has the nice feature that it does not alter column positions of values!

For JSON content, this will have no semantic impact, since indentations in JSON is always meaningless.

In YAML files, if the tabs appear in flow context this only changes ignored whitespace. In block content, it means the original YAML file was invalid, but assuming tabs were used consistently to indent the YAML, this change will preserve block levels and so might actually cause such files to be valid YAML.

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