Is it bug? Only n and y have string double quot

Jul 19, 2013 at 1:35 PM
Hi.

I used all of alphabet keys.

I coded like below.
[CODE]
    var playerSeq =
        new YamlMapping(
             // key
            new YamlScalar("Players"),
            // sequence
            new YamlSequence(
                new YamlMapping(
                    new YamlScalar("Name"), new YamlScalar("Samurai"),
                    new YamlScalar("Hp"), 122,
                    new YamlScalar("Rarity"), 12,
                    new YamlScalar("Scale"), new YamlMapping(
                        new YamlScalar("a"), 100,
                        new YamlScalar("b"), 100,
                        new YamlScalar("c"), 100,
                        new YamlScalar("d"), 100,
                        new YamlScalar("e"), 100,
                        new YamlScalar("f"), 100,
                        new YamlScalar("g"), 100,
                        new YamlScalar("h"), 100,
                        new YamlScalar("i"), 100,
                        new YamlScalar("j"), 100,
                        new YamlScalar("k"), 100,
                        new YamlScalar("l"), 100,
                        new YamlScalar("m"), 100,
                        new YamlScalar("n"), 9999,
                        new YamlScalar("o"), 100,
                        new YamlScalar("p"), 100,
                        new YamlScalar("q"), 100,
                        new YamlScalar("r"), 100,
                        new YamlScalar("s"), 100,
                        new YamlScalar("t"), 300,
                        new YamlScalar("u"), 100,
                        new YamlScalar("v"), 100,
                        new YamlScalar("w"), 100,
                        new YamlScalar("x"), 100,
                        new YamlScalar("y"), 100,
                        new YamlScalar("z"), -1
                    ),
                    new YamlScalar("charactr_id"), new YamlScalar("11100011")
                ),
                new YamlMapping(
                    "Name", new YamlScalar("Long"),
                    new YamlScalar("Hp"), 122,
                    new YamlScalar("Rarity"), 12,
                    new YamlScalar("Scale"), new YamlMapping(
                        new YamlScalar("a"), 100,
                        new YamlScalar("b"), 100,
                        new YamlScalar("c"), 100,
                        new YamlScalar("d"), 100,
                        new YamlScalar("e"), 100,
                        new YamlScalar("f"), 100,
                        new YamlScalar("g"), 100,
                        new YamlScalar("h"), 100,
                        new YamlScalar("i"), 100,
                        new YamlScalar("j"), 100,
                        new YamlScalar("k"), 100,
                        new YamlScalar("l"), 100,
                        new YamlScalar("m"), 100,
                        new YamlScalar("n"), 19191919,
                        new YamlScalar("o"), 100,
                        new YamlScalar("p"), 100,
                        new YamlScalar("q"), 100,
                        new YamlScalar("r"), 100,
                        new YamlScalar("s"), 100,
                        new YamlScalar("t"), 300,
                        new YamlScalar("u"), 100,
                        new YamlScalar("v"), 100,
                        new YamlScalar("w"), 100,
                        new YamlScalar("x"), 100,
                        new YamlScalar("y"), 100,
                        new YamlScalar("z"), -1
                    ),
                    new YamlScalar("charactr_id"), new YamlScalar("11100012")
                )
            )
        );

        playerSeq.ToYamlFile("somepath");
[/CODE]

And the YAML file is like that.

%YAML 1.2

Players:
  • Name: Samurai
    Hp: 122
    Rarity: 12
    Scale:
    s: 100
    t: 300
    p: 100
    q: 100
    r: 100
    m: 100
    "n": 9999
    o: 100
    k: 100
    l: 100
    x: 100
    "y": 100
    z: -1
    u: 100
    v: 100
    w: 100
    h: 100
    i: 100
    j: 100
    e: 100
    f: 100
    g: 100
    c: 100
    d: 100
    a: 100
    b: 100
    charactr_id: "11100011"
  • Name: Long
    Hp: 122
    Rarity: 12
    Scale:
    s: 100
    t: 300
    p: 100
    q: 100
    r: 100
    m: 100
    "n": 19191919
    o: 100
    k: 100
    l: 100
    x: 100
    "y": 100
    z: -1
    u: 100
    v: 100
    w: 100
    h: 100
    i: 100
    j: 100
    e: 100
    f: 100
    g: 100
    c: 100
    d: 100
    a: 100
    b: 100
    charactr_id: "11100012"
    ...
"n" and "y" have double quot.
Why do they have it?
Coordinator
Jul 19, 2013 at 1:56 PM
According to my understanding, YAML 1.1 resolves naked string y and n without
quatation as true and false of !!bool type, though this rule does not seem
to me very useful.

http://yaml.org/type/bool.html

This resolution rule is implemented in YamlTagResolutionScheme.cs as:
        AddRule<bool>("!!bool", @"y|Y|yes|Yes|YES|true|True|TRUE|on|On|ON", m => true, null);
        AddRule<bool>("!!bool", @"n|N|no|No|NO|false|False|FALSE|off|Off|OFF", m => false, null);
You can safely modify these lines to suppress double quotation around n and y of string type.
        AddRule<bool>("!!bool", @"true|True|TRUE", m => true, null);
        AddRule<bool>("!!bool", @"false|False|FALSE", m => false, null);