Skip to content

Change Case with ConvertTo-PSFHashTable -Remap param #641

@Callidus2000

Description

@Callidus2000

Hi Fred,
I need to convert parameters to a specific camelcase (for forwarding case insensitive function parameters to a case sensitive REST API).

Normally I use $PSBoundParameters | ConvertTo-PSFHashTable for generating the parameter variable, but with the case sensitivity it's not working.

# Example HashTable with missmatching case - API needs param lowercase
C:\> @{HubbA=123}|ConvertTo-Json -Compress
{"HubbA":123}

# Trying to use the remap param for it does not return a result at all
C:\> @{HubbA=123}|ConvertTo-PSFHashtable -Remap @{hubba='hubba'}|ConvertTo-Json -Compress
{}

# Adding CaseSenitive switch does generate a result, but the wrong one
C:\> @{HubbA=123}|ConvertTo-PSFHashtable -Remap @{hubba='hubba'} -CaseSensitive|ConvertTo-Json -Compress
{"HubbA":123}

# Doing it twice does the job but is ugly
C:\> @{HubbA=123}|ConvertTo-PSFHashtable -Remap @{hubba='bubba'}|ConvertTo-PSFHashtable -Remap @{bubba='hubba'}|ConvertTo-Json -Compress
{"hubba":123}

Could such thing be added?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions