You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
I also noticed that using yaml parseDocument instead of parse function works better.
const YAML = require('yaml');
const parsed = YAML.parseDocument("'... this is a test': this is the value");
const stringified = YAML.stringify(parsed);
const reparsed = YAML.parse(stringified);
f4b1ux
changed the title
Parse/stringify of keys containing "..."
Parse/stringify of keys containing ...Dec 28, 2022
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
Expected behaviour
Keys containing token such as "..." or "---" should be automatically placed in quotes on stringify.
Versions (please complete the following information):
yaml
: 2.2.0Additional context
A workaround is to specify
defaultKeyType
option inside stringify options toQUOTE_SINGLE
orQUOTE_DOUBLE
. This causes that ALL keys will be single (or double) quoted.The text was updated successfully, but these errors were encountered: