Skip to content

Status of fix for losing case-sensitive keys #191

Closed

Description

@ThaDaVos

Currently when your YAML contains case-sensitive keys, only the last one is kept - I ran into this as I am using powershell-yaml to cleanup an OpenAPI Spec file (of which I have not control) and the authors of it made the great decision to have multiple paths duplicated only by case.

Sadly because of the revert of the fix in #159 - mentioned in https://github.com/cloudbase/powershell-yaml/releases/tag/v0.4.9 - loading the YAML results in losing these duplicate keys

So, is there an update on a fix for this? Perhaps placed behind a flag like casesensitive so when needed, one can use it?

Activity

  1. gabriel-samfira commented on May 12, 2025

    @gabriel-samfira
    Member

    I will try to push a fix this week. For compatibility, there will probably be a flag to set for case sensitive keys (I really want to avoid having to revert again). Luckily, powershell allows us to set default values for parameters of specific commandlets using something like:

    # Not an option yet. Will probably be added soon.
    $PSDefaultParameterValues=@{"ConvertFrom-Yaml:UseCaseSensitiveKeys"=$true}

    This can be set at the beginning of a powershell script and will be applied automatically whenever you run ConvertFrom-Yaml.

    Thanks for reminding me of this.

  2. gabriel-samfira commented on Jan 4, 2026

    @gabriel-samfira
    Member

    Hi @ThaDaVos

    I realize this is late, but if you still need this, I have a PR up that might help. I say might, because while it does not bring back the behavior in #159 , it does add the ability to model the yaml using powershell classes, and map case sensitive keys to specific class properties.

    The PR is here:

    Example usage here:

    https://github.com/gabriel-samfira/powershell-yaml/blob/0376d2e7e513719de778a86fa30d3aaab4da1edd/examples/yamlkey-attribute.ps1#L27-L31

    And the class that models that yaml is here:

    https://github.com/gabriel-samfira/powershell-yaml/blob/models/examples/classes/ServerConfig.ps1

    The last time I changed the default behavior of the commandlets, it broke a lot of people's scripts, so I am hesitant to change it back, but we can add new functionality that enables more flexibility.

  3. gabriel-samfira commented on Jan 5, 2026

    @gabriel-samfira
    Member

    the above mentioned PR was merged. Closing this for now. Feel free to reopen if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions