keyvalues-python icon indicating copy to clipboard operation
keyvalues-python copied to clipboard

Issue with "array"

Open Paaskehare opened this issue 11 years ago • 0 comments

Tried to parse this:

{
        "Hero"          "lion"
        "Title"         "Lion (Scratch)"
        "GuideRevision"         "1"
        "Scratch"               "1"
        "ItemBuild"
        {
                "Items"
                {
                        "#DOTA_Item_Build_Starting_Items"
                        {
                                "item"          "item_tango"
                                "item"          "item_flask"
                                "item"          "item_courier"
                                "item"          "item_branches"
                                "item"          "item_ward_observer"
                        }
                        "Support"
                        {
                                "item"          "item_ward_observer"
                                "item"          "item_ward_sentry"
                                "item"          "item_smoke_of_deceit"
                                "item"          "item_dust"
                        }
                        "#DOTA_Item_Build_Core_Items"
                        {
                                "item"          "item_magic_wand"
                                "item"          "item_boots"
                                "item"          "item_tranquil_boots"
                                "item"          "item_urn_of_shadows"
                                "item"          "item_force_staff"
                        }
                        "#DOTA_Item_Build_Luxury"
                        {
                                "item"          "item_ghost"
                                "item"          "item_mekansm"
                                "item"          "item_pipe"
                                "item"          "item_blink"
                                "item"          "item_veil_of_discord"
                                "item"          "item_cyclone"
                                "item"          "item_vladmir"
                                "item"          "item_bracer"
                                "item"          "item_necronomicon"
                                "item"          "item_ultimate_scepter"
                                "item"          "item_sheepstick"
                                "item"          "item_travel_boots"
                        }
                }
        }
}

But the KeyValues parser ends up with this:

"HeroGuide"
{
    "Hero" "lion"
    "Title" "Lion (Scratch)"
    "GuideRevision" "1"
    "Scratch" "1"
    "ItemBuild"
    {
        "Items"
        {
            "#DOTA_Item_Build_Starting_Items"
            {
                "item" "item_ward_observer"
            }
            "Support"
            {
                "item" "item_dust"
            }
            "#DOTA_Item_Build_Core_Items"
            {
                "item" "item_force_staff"
            }
            "#DOTA_Item_Build_Luxury"
            {
                "item" "item_travel_boots"
            }
        }
    }
}

As you can see the parser overrides when there are multiple keys with the same name, it should be handled as an array.

Note that this is a valid keyvalues file from the Dota2 Game

Paaskehare avatar Jul 29 '14 23:07 Paaskehare