Skip to content

Parse/stringify of keys containing ... #431

Closed
@f4b1ux

Description

@f4b1ux

Short Description
The library correctly parse a document with a key containing ... in it, if placed in single or double quotes. But when you stringify the obtained json, the result is a key containing ... but without quotes, so when you try to parse it again, library returns a "Unexpected scalar at node end at...".
In YAML ... is document stop token (the counterpart to ---).

To Reproduce

const YAML = require('yaml);

const parsed = YAML.parse("'... this is a test': this is the value");
const stringified = YAML.stringify(parsed);
const reparsed = YAML.parse(stringified)

Expected behaviour
Keys containing token such as "..." or "---" should be automatically placed in quotes on stringify.

Versions (please complete the following information):

  • Environment: Node 18.12.1
  • yaml: 2.2.0

Additional context
A workaround is to specify defaultKeyType option inside stringify options to QUOTE_SINGLE or QUOTE_DOUBLE. This causes that ALL keys will be single (or double) quoted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions