Open eBerdnA opened 1 year ago
In YAML, both single and double quotes denote strings. However, they have slightly different behaviors:
Regarding the behavior you're seeing, this discrepancy is due to how the gopkg.in/yaml.v3 package handles strings when marshalling YAML in Go. The YAML package outputs a valid YAML representation of a string, choosing the appropriate style (plain, single-quoted, or double-quoted) given the content of the string.
Here's a bit more specifics:
Both, single-quoted and double-quoted representations are valid YAML and equivalent in value.
I have the following input file.
Using the following code I get a slightly unexpected result. I use
v3.0.1
andgo1.20.2 darwin/arm64
for this.The output is the following.
My questions is, why is
title
still encapsulated in double quotes buttitle2
is only encapsulated with single quotes andtitle3
even gets switched over. For me this behaviour looks quite confusing and inconsistent.